From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 9 Nov 2022 13:03:31 +0000 From: Alyssa Ross To: Henri Rosten Cc: devel@spectrum-os.org Subject: Re: [PATCH v2] Remove bashisms from spectrum shell scripts Message-ID: <20221109130331.kaqcg5jryiqm23fg@x220> References: <20221109062251.850946-1-henri.rosten@unikie.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="r36d5ufz7vxdaebt" Content-Disposition: inline In-Reply-To: <20221109062251.850946-1-henri.rosten@unikie.com> List-Id: --r36d5ufz7vxdaebt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Nov 09, 2022 at 08:22:51AM +0200, Henri Rosten wrote: > This commit removes bashisms from spectrum shell scripts. This change is > needed to be able to use the scripts from POSIX-compliant shells which > are not bash compatible - such as dash. > > Signed-off-by: Henri Rosten Thanks for v2! I think we're almost there. > --- > Documentation/scripts/undocumented-uuids.sh | 7 ++++++- > scripts/format-uuid.sh | 15 ++++++++++++++- > scripts/make-gpt.sh | 7 +++---- > 3 files changed, 23 insertions(+), 6 deletions(-) > > diff --git a/Documentation/scripts/undocumented-uuids.sh b/Documentation/scripts/undocumented-uuids.sh > index 34c2d22..fa21366 100755 > --- a/Documentation/scripts/undocumented-uuids.sh > +++ b/Documentation/scripts/undocumented-uuids.sh > @@ -1,14 +1,19 @@ > #!/bin/sh -eu > # SPDX-FileCopyrightText: 2022 Alyssa Ross > +# SPDX-FileCopyrightText: 2022 Unikie > # SPDX-License-Identifier: EUPL-1.2+ > > +trap 'rm -f -- "$documented_uuids"' EXIT > + I think this should go immediately after the directory is created, rather than before. > cd "$(dirname "$0")/../.." > > PATTERN='\b[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}\b' > UUID_REFERENCE_PATH=Documentation/uuid-reference.adoc > > +documented_uuids=$(mktemp) > +grep -Eio "$PATTERN" "$UUID_REFERENCE_PATH" | sort -u >$documented_uuids > git ls-files -coz --exclude-standard | > grep -Fxvz "$UUID_REFERENCE_PATH" | > xargs -0 git grep -Ehio --no-index --no-line-number "$PATTERN" -- | > sort -u | > - comm -23 - <(grep -Eio "$PATTERN" "$UUID_REFERENCE_PATH" | sort -u) > + comm -23 - $documented_uuids documented_uuids could contain spaces etc, so I'd like this to be quoted. > diff --git a/scripts/format-uuid.sh b/scripts/format-uuid.sh > index fa07eb9..6758088 100755 > --- a/scripts/format-uuid.sh > +++ b/scripts/format-uuid.sh > @@ -1,6 +1,19 @@ > #!/bin/sh -eu > # > # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross > +# SPDX-FileCopyrightText: 2022 Unikie > # SPDX-License-Identifier: EUPL-1.2+ > > -printf "%s\n" "${1:0:8}-${1:8:4}-${1:12:4}-${1:16:4}-${1:20}" > +substr () { > + str=$1 > + beg=$2 > + end=$3 > + echo $str | cut -c $beg-$end > +} > + > +u1=$(substr $1 1 8) > +u2=$(substr $1 9 12) > +u3=$(substr $1 13 16) > +u4=$(substr $1 17 20) > +u5=$(substr $1 21 32) > +printf "%s\n" "$u1-$u2-$u3-$u4-$u5" This one looks good now, thanks. > diff --git a/scripts/make-gpt.sh b/scripts/make-gpt.sh > index 56076d3..351aa69 100755 > --- a/scripts/make-gpt.sh > +++ b/scripts/make-gpt.sh > @@ -1,6 +1,7 @@ > #!/bin/sh -eu > # > # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross > +# SPDX-FileCopyrightText: 2022 Unikie > # SPDX-License-Identifier: EUPL-1.2+ > # > # usage: make-gpt.sh GPT_PATH PATH:PARTTYPE[:PARTUUID]... > @@ -38,7 +39,7 @@ scriptsDir="$(dirname "$0")" > out="$1" > shift > > -nl=$'\n' > +nl='\n' > table="label: gpt" > > # Keep 1MiB free at the start, and 1MiB free at the end. > @@ -51,9 +52,7 @@ done > > rm -f "$out" > truncate -s "$gptBytes" "$out" > -sfdisk "$out" < -$table > -EOF > +printf "$table" | sfdisk "$out" I put a suggestion for this one in the other email I just sent. :) > > n=0 > for partition; do --r36d5ufz7vxdaebt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEH9wgcxqlHM/ARR3h+dvtSFmyccAFAmNrpSEACgkQ+dvtSFmy ccCc+hAAqXPxqA2PgwKAna5D+uFN2hOpyIqgXqcqxm61DKh6ySrKi6Bbrytb4y4b ntY3yVMCmpgy7WQqQfesDk+xd+L2QvQ3BXr7JP1+j9uqyrisUDIOBwLG1C/G60Fl LjrBILu+XhmqPgne/1C26rSKgcqDWIwcZZFZ9Abs1K3MUzOBA5mM/iJo0yUIRV+/ BPvGIMhgIUwtK1g72cpI13ih/0AYMObkzUbCQsbn5LRoG+lXTkfnysymCTmmKgcE 5JBRrdonITlr4cR9ux4dOVaRKBKW4GfonmYya2xICn2g5Z1a7P8WwmZIGo+2Nhoh PSiaXGFaZDM52qZkeqyW3UdBWB8enuaSKDNyUn/FQwpOEnUgSOrZpWduRzUH15J3 1ysgIPmJFJ6jMSepd308aoTeCMSpHuQBLr0xcOKDikANlAEdjmy/HX3DGuri4ZF3 FJREirAigYHONXj3rB62Q7lWgWZUbXKC5mvSafUoRjGSjP38elaJbQGlFQCW7Ntm pQsl8eoU1jahb3V9GVe6+R+WS7w0HU1aTlVZZuO6SK9uJV9qghsSHIOi4XdcymTO WMAWVyW3HcBWxRlHLzk6WcBsR8LhogyGahb4j6nCCEGsw0ciYOOkCw7R9S11Lr7s NGkMTsP+W1HsDfJn/j7rAuMYpGiSZvjZIrqbtNoYMJH/uOtprJ4= =aCfi -----END PGP SIGNATURE----- --r36d5ufz7vxdaebt--