From: Jonatan Schlag Date: Sun, 16 Jun 2024 16:02:43 +0000 (+0200) Subject: initscripts fkt: keep readhash compatible with older implementation X-Git-Tag: v2.29-core189~65^2~78 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=14ecdd86f1e57949858b47aa2a449e051bf3ee3a;p=ipfire-2.x.git initscripts fkt: keep readhash compatible with older implementation With the use of eval BLUE_DEV='blue0 net0' stored "blue0 net0" in the variable BLUE_DEV not "'blue0 net0'" Signed-off-by: Jonatan Schlag Signed-off-by: Michael Tremer --- diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 84aaf251ad..46bef41c36 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -931,6 +931,10 @@ readhash() { continue fi + # strip leading and trailing single quotes + val="${val#\'}" + val="${val%\'}" + printf -v "${array}[${key}]" "%s" "${val}" done < "${file}" } diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh index a2d6535a52..e7f695f55f 100755 --- a/tests/src/initscripts/system/functions/test.sh +++ b/tests/src/initscripts/system/functions/test.sh @@ -14,6 +14,7 @@ readhash "CONFIG" "${SCRIPT_PATH}/data/1" # test if we read the correct data test_value_in_array "CONFIG" "RED_DHCP_HOSTNAME" "ipfire" test_value_in_array "CONFIG" "BLUE_MACADDR" "bc:30:7d:58:6b:e3" +test_value_in_array "CONFIG" "BLUE_DEV" "blue0 net0" # Test that comments are skipped # apparently the way we read the file strips the whitespace, so the key does not contain any whitespace either