From: Jonatan Schlag <jonatan.schlag@ipfire.org>
To: development@lists.ipfire.org
Subject: Re: [PATCH 13/21] initscript fkt: ignore blank lines in readhash
Date: Sun, 02 Jun 2024 20:07:37 +0200 [thread overview]
Message-ID: <7c93843e3978ecf281af842ae94220a678a49ce6.camel@ipfire.org> (raw)
In-Reply-To: <2F5DC8C8-DA61-4C2B-9F04-9A6DA689DBF5@ipfire.org>
[-- Attachment #1: Type: text/plain, Size: 3106 bytes --]
Hi,
Am Freitag, dem 31.05.2024 um 10:55 +0100 schrieb Michael Tremer:
>
>
> > On 20 May 2024, at 10:06, Jonatan Schlag
> > <jonatan.schlag(a)ipfire.org> wrote:
> >
> > Signed-off-by: Jonatan Schlag <jonatan.schlag(a)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#*=}"
>
> I don’t think this is quite sufficient.
>
> You might have other lines that are invalid. For example “=VALUE”. I
> think we should check that key isn’t empty, and we should limit what
> characters can be used in keys and values as it used to be before in
> the script.
>
> https://git.ipfire.org/?p=ipfire-2.x.git;a=blob;f=src/scripts/readhash;h=bffc93fbd00c31a76e9c96fc17dabf0a87c3c9ef;hb=HEAD
>
Hi,
I will merge all commits for checks in the next series. There are more
checks to come. In a later commit, I check for correct values and keys.
Jonatan
> >
> > 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 ec502e199..8d644b8cd 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_that_key_in_arry_has_value "CONFIG" "RED_DHCP_HOSTNAME"
> > "ipfire"
> > test_that_key_in_arry_has_value "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"
> > --
> > 2.39.2
> >
>
next parent reply other threads:[~2024-06-02 18:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <2F5DC8C8-DA61-4C2B-9F04-9A6DA689DBF5@ipfire.org>
2024-06-02 18:07 ` Jonatan Schlag [this message]
2024-06-03 9:21 ` Michael Tremer
2024-05-20 9:05 First patch series for the roadmap item "Get rid of CONFIG_TYPE in the network config" Jonatan Schlag
2024-05-20 9:06 ` [PATCH 13/21] initscript fkt: ignore blank lines in readhash 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=7c93843e3978ecf281af842ae94220a678a49ce6.camel@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