]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
initscripts fkt: keep readhash compatible with older implementation
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Sun, 16 Jun 2024 16:02:43 +0000 (18:02 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 24 Aug 2024 12:19:56 +0000 (12:19 +0000)
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 <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/initscripts/system/functions
tests/src/initscripts/system/functions/test.sh

index 84aaf251ada55e8f52216bce5561f323c426f7ac..46bef41c364b055f95316433ff1d3346584b3988 100644 (file)
@@ -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}"
 }
index a2d6535a525b01c7fd9ddd96419dc8752c95fe4f..e7f695f55fba7498ab670250b929f488b76f6b68 100755 (executable)
@@ -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