From afd622429815af7e9f80771405d0a5d631c0ab4e Mon Sep 17 00:00:00 2001 From: David le Blanc Date: Mon, 13 Dec 2021 16:05:47 +1100 Subject: [PATCH 1/2] Fixed config file parsing to handle "=" in value field. --- lib/utils.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils.bash b/lib/utils.bash index 91c06c517..df0c9430d 100644 --- a/lib/utils.bash +++ b/lib/utils.bash @@ -357,7 +357,7 @@ get_asdf_config_value_from_file() { fi local result - result=$(grep -E "^\\s*$key\\s*=\\s*" "$config_path" | head | awk -F '=' '{print $2}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + result=$(grep -E "^\\s*$key\\s*=\\s*" "$config_path" | head | sed -e 's/^[^=]*= *//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') if [ -n "$result" ]; then printf "%s\\n" "$result" return 0 From b2b71e64024345fe1d5caba7930801a8e40dcc1e Mon Sep 17 00:00:00 2001 From: David le Blanc Date: Wed, 15 Dec 2021 19:29:08 +1100 Subject: [PATCH 2/2] Added test for handling config file values containing "=" in their text --- test/get_asdf_config_value.bats | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/get_asdf_config_value.bats b/test/get_asdf_config_value.bats index 1755ab507..ad341d490 100644 --- a/test/get_asdf_config_value.bats +++ b/test/get_asdf_config_value.bats @@ -38,3 +38,11 @@ teardown() { [ $(get_asdf_config_value "key1") = "value1" ] [ $(get_asdf_config_value "legacy_version_file") = "yes" ] } + +@test "get_config returns config file complete value including '=' symbols" { + cat >> $ASDF_CONFIG_FILE <<-'EOM' +key3 = VAR=val +EOM + + [ $(get_asdf_config_value "key3") = "VAR=val" ] +}