From: Jonatan Schlag <jonatan.schlag@ipfire.org>
To: development@lists.ipfire.org
Subject: [PATCH v2 16/18] initscripts fkt: keep readhash compatible with older implementation
Date: Sun, 16 Jun 2024 18:02:43 +0200 [thread overview]
Message-ID: <20240616160245.18865-17-jonatan.schlag@ipfire.org> (raw)
In-Reply-To: <20240616160245.18865-1-jonatan.schlag@ipfire.org>
[-- Attachment #1: Type: text/plain, Size: 1442 bytes --]
With the use of eval BLUE_DEV='blue0 net0' stored "blue0 net0" in the
variable BLUE_DEV not "'blue0 net0'"
Signed-off-by: Jonatan Schlag <jonatan.schlag(a)ipfire.org>
---
src/initscripts/system/functions | 4 ++++
tests/src/initscripts/system/functions/test.sh | 1 +
2 files changed, 5 insertions(+)
diff --git a/src/initscripts/system/functions b/src/initscripts/system/functions
index c9c4c0675..6d72e4119 100644
--- a/src/initscripts/system/functions
+++ b/src/initscripts/system/functions
@@ -932,6 +932,10 @@ readhash() {
continue
fi
+ # strip leading and trailing single quotes
+ val="${val#\'}"
+ val="${val%\'}"
+
printf -v "${array}[${key}]" "%s" "${val}"
done < "${file}"
}
diff --git a/tests/src/initscripts/system/functions/test.sh b/tests/src/initscripts/system/functions/test.sh
index a2d6535a5..e7f695f55 100755
--- a/tests/src/initscripts/system/functions/test.sh
+++ b/tests/src/initscripts/system/functions/test.sh
@@ -14,6 +14,7 @@ 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_value_in_array "CONFIG" "BLUE_DEV" "blue0 net0"
# Test that comments are skipped
# apparently the way we read the file strips the whitespace, so the key does not contain any whitespace either
--
2.39.2
next prev parent reply other threads:[~2024-06-16 16:02 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-16 16:02 v2 First patch series for the roadmap item "Get rid of CONFIG_TYPE in the network config" Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 01/18] tests: Add bash lib Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 02/18] tests/lib.sh: Add function test_value_in_array Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 03/18] tests/lib.sh: Add check if variable exists to test_value_in_array Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 04/18] tests/lib.sh: Add logging functions Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 05/18] tests/lib.sh: adjust to pytest logging style Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 06/18] test_value_in_array: Check if the key is defined Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 07/18] tests: Add function to test the ouput of a bash function Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 08/18] test: Add functions test_that_array_is_defined Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 09/18] tests: Add functions test_that_array_doesnt_have_key Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 10/18] initscript functions: add readhash Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 11/18] initscript fkt: ignore blank lines in readhash Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 12/18] initscripts fkt: Ignore comments " Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 13/18] initscripts fkt: ignore invalid keys " Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 14/18] initscripts fkt: Check for invalid values " Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 15/18] initscripts fkt: readhash should only parse lines with a = Jonatan Schlag
2024-06-16 16:02 ` Jonatan Schlag [this message]
2024-06-16 16:02 ` [PATCH v2 17/18] initscripts fkt: Fix shebang Jonatan Schlag
2024-06-16 16:02 ` [PATCH v2 18/18] initscripts fkt: Check that readhash returns 1 on a missing file Jonatan Schlag
2024-07-06 17:58 ` v2 First patch series for the roadmap item "Get rid of CONFIG_TYPE in the network config" Jonatan Schlag
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240616160245.18865-17-jonatan.schlag@ipfire.org \
--to=jonatan.schlag@ipfire.org \
--cc=development@lists.ipfire.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox