]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
initscript fkt: ignore blank lines in readhash
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Sun, 16 Jun 2024 16:02:38 +0000 (18:02 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 24 Aug 2024 12:19:56 +0000 (12:19 +0000)
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/data/1_output_stderr [new file with mode: 0644]
tests/src/initscripts/system/functions/data/1_output_stdout [new file with mode: 0644]
tests/src/initscripts/system/functions/test.sh

index dd141db6e85fd8b073a474dbe52f6d0798df5d73..507ebb7c5d4d96ef26a5fba4d555d0f8e7e08ec4 100644 (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#*=}"
 
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 (file)
index 0000000..e69de29
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 (file)
index 0000000..e69de29
index dbb2d8a6222d1c1ab3c57559b367a443c000ac7b..751be68844055649080e6d89bd3655b3b4da0621 100755 (executable)
@@ -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"