From: Jonatan Schlag Date: Sun, 16 Jun 2024 16:02:38 +0000 (+0200) Subject: initscript fkt: ignore blank lines in readhash X-Git-Tag: v2.29-core189~65^2~83 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=59e3c2a217e7b219c62fe07f702ead9594b1ac24;p=ipfire-2.x.git initscript fkt: ignore blank lines in readhash Signed-off-by: Jonatan Schlag Signed-off-by: Michael Tremer --- diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index dd141db6e8..507ebb7c5d 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -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#*=}" diff --git a/tests/src/initscripts/system/functions/data/1_output_stderr b/tests/src/initscripts/system/functions/data/1_output_stderr new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/src/initscripts/system/functions/data/1_output_stdout b/tests/src/initscripts/system/functions/data/1_output_stdout new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh index dbb2d8a622..751be68844 100755 --- a/tests/src/initscripts/system/functions/test.sh +++ b/tests/src/initscripts/system/functions/test.sh @@ -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"