From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonatan Schlag To: development@lists.ipfire.org Subject: [PATCH v2 11/18] initscript fkt: ignore blank lines in readhash Date: Sun, 16 Jun 2024 18:02:38 +0200 Message-ID: <20240616160245.18865-12-jonatan.schlag@ipfire.org> In-Reply-To: <20240616160245.18865-1-jonatan.schlag@ipfire.org> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============2844282295452443634==" List-Id: --===============2844282295452443634== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Signed-off-by: Jonatan Schlag --- 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_stde= rr create mode 100644 tests/src/initscripts/system/functions/data/1_output_stdo= ut diff --git a/src/initscripts/system/functions b/src/initscripts/system/functi= ons index 44ce999d3..3f01be9e0 100644 --- a/src/initscripts/system/functions +++ b/src/initscripts/system/functions @@ -900,6 +900,12 @@ readhash() { =20 local line while read -r line; do + + # Skip Blank Lines + if [[ ${line} =3D~ ^[[:space:]]*$ ]]; then + continue + fi + local key=3D"${line%=3D*}" local val=3D"${line#*=3D}" =20 diff --git a/tests/src/initscripts/system/functions/data/1_output_stderr b/te= sts/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/te= sts/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/inits= cripts/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 "CONF= IG" "${SCRIPT_PATH}/data/1" +test_that_output_is "${SCRIPT_PATH}/data/1_output_stderr" "2" readhash "CONF= IG" "${SCRIPT_PATH}/data/1" --=20 2.39.2 --===============2844282295452443634==--