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 <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
This commit is contained in:
Jonatan Schlag
2024-06-16 18:02:43 +02:00
committed by Michael Tremer
parent f1d94e7457
commit 14ecdd86f1
2 changed files with 5 additions and 0 deletions

View 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}"
}

View File

@@ -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