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 34CB812933; Tue, 8 Nov 2022 10:08:55 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id 34BCB12925; Tue, 8 Nov 2022 10:08:53 +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-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by atuin.qyliss.net (Postfix) with ESMTPS id 381051298B for ; Tue, 8 Nov 2022 10:08:50 +0000 (UTC) Received: by mail-lj1-x22c.google.com with SMTP id s24so20321150ljs.11 for ; Tue, 08 Nov 2022 02:08:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unikie.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=U0NcwUCPoX9scuNqhWoEpO+GdX+juk01s44tuz5kBwU=; b=G9WGvg7ovHAZqFVgBlopcIAq49K1TWWv5DTroBeBzObOuruEBAc7VzbMIjNWwh70n2 rujYD48e+VATj3X++Pw/nQA7cMsAB0HMj0CKRZz9LXqYe54aplgxlj1w6cDUoWScf+Bz tJZnrs3+oI2LCFFX8v8l0NVbbDtJsmXTiW1Rx3zLLz9tJPzhuof3PaBMiEU+GPg5a2M5 PYK2hwF8TJezcpTXLjpLA9OKhfNJC9xNqjRmykPgAL0LqTBTaqnrFnXl6VufqXWU6JWi bHRcS9F3Yqyv++oSJiyFMkfhyjRLHfwzLo5dCnWvr9S+/qtjqDFuORhnhtvt9LOazPbB UsNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=U0NcwUCPoX9scuNqhWoEpO+GdX+juk01s44tuz5kBwU=; b=dWsNLt5mu9AbYuB4peNYLkAkCgiyuD0I14hkzG7P+WV0URBa1eb/fIsRf8C5dAO2gq ADmxlpNLAkGjVAg06P/OGBPi7YamI0eH75CGoKRG4Q5em8+O4dxAbqXUGUnL1joHSCB8 IeyHqCQfVJb1eB++RTN+ylwRdH72nNkvMtnzyqtcHm4DCPyw2/4iZiOFCfVJg2fJ9Qh0 QF03u8ZkDuuWy7TeItxmcHUb3OnA3Hq7KxD9JXXafMOqE0/83C736mMG85pcit+msNSR Th4eF9wntalrzVe4/b67Z0o+5QnIkZK57T6Erk7biVau8ob5MJLYaEjOf61PvNVwJEwn a7tw== X-Gm-Message-State: ANoB5ple1pAaG0NMqXdRc9P8IgmqEH8UvhQHsfo4pnX2KqUF6G/pqyzV 67ahAYPh4AC9QiZ0d8wm7N+aepZf0GAn0Q== X-Google-Smtp-Source: AA0mqf7HJstAp/ykazkSINw8zO9v/BtwKw85h8KecXY0owW71aRZ7UHRQ/+TdpKoSXx0NZ2X7LkpSg== X-Received: by 2002:a2e:850c:0:b0:277:94f1:fc80 with SMTP id j12-20020a2e850c000000b0027794f1fc80mr6010658lji.510.1667902127808; Tue, 08 Nov 2022 02:08:47 -0800 (PST) Received: from buamix.lan (86-60-162-79.dynamic.lounea.fi. [86.60.162.79]) by smtp.gmail.com with ESMTPSA id g29-20020a0565123b9d00b004a47a92ff4csm1705916lfv.193.2022.11.08.02.08.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 02:08:47 -0800 (PST) From: Henri Rosten To: devel@spectrum-os.org Subject: [PATCH] Remove bashisms from spectrum shell scripts Date: Tue, 8 Nov 2022 12:05:44 +0200 Message-Id: <20221108100544.721808-1-henri.rosten@unikie.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: WMKZPOCJ4ONLGMWWUVLGPB3EDODUWN7Z X-Message-ID-Hash: WMKZPOCJ4ONLGMWWUVLGPB3EDODUWN7Z 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: Henri Rosten 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: c4iJkTuXjyqW 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 --- Documentation/scripts/undocumented-uuids.sh | 6 +++++- scripts/format-uuid.sh | 15 ++++++++++++++- scripts/make-gpt.sh | 7 +++---- 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Documentation/scripts/undocumented-uuids.sh b/Documentation/scripts/undocumented-uuids.sh index 34c2d22..0434407 100755 --- a/Documentation/scripts/undocumented-uuids.sh +++ b/Documentation/scripts/undocumented-uuids.sh @@ -1,5 +1,6 @@ #!/bin/sh -eu # SPDX-FileCopyrightText: 2022 Alyssa Ross +# SPDX-FileCopyrightText: 2022 Unikie # SPDX-License-Identifier: EUPL-1.2+ cd "$(dirname "$0")/../.." @@ -7,8 +8,11 @@ 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 +tmp=$(mktemp) +grep -Eio "$PATTERN" "$UUID_REFERENCE_PATH" | sort -u >$tmp 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 - $tmp +rm -f $tmp diff --git a/scripts/format-uuid.sh b/scripts/format-uuid.sh index fa07eb9..c7b94da 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 $(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" 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" <