Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/initscripts/system/functions | 6 ++++++ tests/src/initscripts/system/functions/data/1_output_stderr | 0 tests/src/initscripts/system/functions/data/1_output_stdout | 0 tests/src/initscripts/system/functions/test.sh | 3 +++ 4 files changed, 9 insertions(+) create mode 100644 tests/src/initscripts/system/functions/data/1_output_stderr create mode 100644 tests/src/initscripts/system/functions/data/1_output_stdout
diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions index 44ce999d3..3f01be9e0 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -900,6 +900,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 000000000..e69de29bb 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 000000000..e69de29bb diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh index dbb2d8a62..751be6884 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"