initscript fkt: ignore blank lines in readhash

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:38 +02:00
committed by Michael Tremer
parent 96bb3ba8b8
commit 59e3c2a217
4 changed files with 9 additions and 0 deletions

View File

@@ -899,6 +899,12 @@ readhash() {
local line
while read -r line; do
# Skip Blank Lines
if [[ ${line} =~ ^[[:space:]]*$ ]]; then
continue
fi
local key="${line%=*}"
local val="${line#*=}"

View File

@@ -14,3 +14,6 @@ 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_that_output_is "${SCRIPT_PATH}/data/1_output_stdout" "1" readhash "CONFIG" "${SCRIPT_PATH}/data/1"
test_that_output_is "${SCRIPT_PATH}/data/1_output_stderr" "2" readhash "CONFIG" "${SCRIPT_PATH}/data/1"