From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 9BD3822AF1; Wed, 9 Nov 2022 13:30:08 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id 7B6D822B4B; Wed, 9 Nov 2022 13:30:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,LOTS_OF_MONEY,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by atuin.qyliss.net (Postfix) with ESMTPS id B3CD122B49 for ; Wed, 9 Nov 2022 13:30:02 +0000 (UTC) Received: by mail-lf1-x12a.google.com with SMTP id b3so25622875lfv.2 for ; Wed, 09 Nov 2022 05:30:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unikie.com; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=qJtqKCQV8KIdEXDfeno2Ia8NMlXJ29rqBws/w47yzX0=; b=dVcjm1KQAvW6MQIHnFzV3PgrEFA0F+o6h1hV84Mdy5shFXCcAP0O0UjhEEJSDTN2Jk 38N220o7Cr6JnldoDTLHB2Zi7W9gNr5LyyOLyeX4lVU43yrF2w0hdZfY2N64w0bkE4Wx oOGBFVwJbuDZ/t0eIfXkZ2J5kiT+jvtoHSutTin7yAna/ObGBjn7hgJb4lhTwds5pOP7 v1ZJu8MD9nsqAF3XadbwwioX0xh7Ejo7aKVpSAJE0Dkb6XkOgzfi4NH7mCeq6TXxtPm0 tCe2pd8Bl3yQ52XlHYgSJCOwKU8vbXnGYdS8l5rA8StGoCkRMYn2WI/DhsWk+c11utW1 aALw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=qJtqKCQV8KIdEXDfeno2Ia8NMlXJ29rqBws/w47yzX0=; b=1/cVn06nv6GMPELSCCAdIfuraqQYNNiWHUcU4Mx1q9bsObAG93p9g+Xmqios6V+57V ZKY31tTJKpe0jswXQk1DeQAaC9UuyMeh2cwZ18JK1nLcoheDT741KqnXpdP7NgPjuThS /K7gtVTgsLo4bSt7NrBMsuqh/znEIihYz4Y+OxcprejMrfYqh1choz1NGSrpw43XoJm1 oYjkfAOIGicJaBTrQiU8vMEV+mXdJ3y0XgHBa+PB0dXF0+KrN7z6UVO8qb+i7O5rfFLE NQRRXmUcU2Q4MBhCniYFlI3McfX2mMFabkGTHdntc6Rrf8Mffe0EZTRi1Dq7JmzWYYX2 JLEA== X-Gm-Message-State: ACrzQf2m4pCNa0mJEmTEfs3BKD0OdWllXcgtSVIOG2x7vuxQ1Hgk0haK 2mohnKNfx3H+KKqoKqQdkmdoYQ== X-Google-Smtp-Source: AMsMyM6GuVFYaKAqQt7EK716LCT3RPeou2b81DZanFP5jmGpoR5cJ0elEUPIP67vvZ1K6H3oKO5TIQ== X-Received: by 2002:a05:6512:54d:b0:4a2:5c54:73e8 with SMTP id h13-20020a056512054d00b004a25c5473e8mr20565740lfl.594.1668000601776; Wed, 09 Nov 2022 05:30:01 -0800 (PST) Received: from buamix (86-60-162-79.dynamic.lounea.fi. [86.60.162.79]) by smtp.gmail.com with ESMTPSA id k8-20020ac24f08000000b004b18698c558sm2217558lfr.46.2022.11.09.05.30.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 05:30:01 -0800 (PST) Date: Wed, 9 Nov 2022 15:30:00 +0200 From: Henri Rosten To: Alyssa Ross Subject: Re: [PATCH v2] Remove bashisms from spectrum shell scripts Message-ID: <20221109133000.GA940835@buamix> References: <20221109062251.850946-1-henri.rosten@unikie.com> <20221109130331.kaqcg5jryiqm23fg@x220> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221109130331.kaqcg5jryiqm23fg@x220> Message-ID-Hash: X7JVDN4YZYDJUA4JFYDLWCLJCAZ5QTAM X-Message-ID-Hash: X7JVDN4YZYDJUA4JFYDLWCLJCAZ5QTAM X-MailFrom: henri.rosten@unikie.com X-Mailman-Rule-Hits: header-match-devel.spectrum-os.org-0 X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1 CC: devel@spectrum-os.org X-Mailman-Version: 3.3.5 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-TUID: nZEc8gmlq/ct On Wed, Nov 09, 2022 at 01:03:31PM +0000, Alyssa Ross wrote: > 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. > Fixed in v3. > > 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. > Thanks, this is now fixed in v3. Also, I notice the Documentation/uuid-reference.adoc was moved to Documentation/appendices/uuid-reference.adoc. Fixed the uuid-reference.adoc path used in this script in v3 too. > > 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. :) > Thanks, this is also fixed in v3. > > > > n=0 > > for partition; do