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 48F2A227BD; Wed, 9 Nov 2022 12:59:24 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id CA0E12277B; Wed, 9 Nov 2022 12:59:21 +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,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 Received: from mail-lf1-x133.google.com (mail-lf1-x133.google.com [IPv6:2a00:1450:4864:20::133]) by atuin.qyliss.net (Postfix) with ESMTPS id E123C2277A for ; Wed, 9 Nov 2022 12:59:19 +0000 (UTC) Received: by mail-lf1-x133.google.com with SMTP id l12so14364491lfp.6 for ; Wed, 09 Nov 2022 04:59:19 -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=T1nVj3BWOgt2evYTdOqseILrUNzoAtjLuPfGfNtwqRk=; b=WIzmpJ3y+rxOIk7XA86ksEnfWgga//pyqb6F9T7bq8ieS+D1w5tl97SfY0beRPfCrs 0JYLgcLr3uzkA4skjs8KYQVxpqDUzKHuPa+l1WfuMdwhtjunuqehNbZNg4t/eKqhhQGi rgso4J5tREKG5HcBHt7KuP8gCNLm7k9+GqlHJ1fkzsJZNJKqD3G9cMy0iA+UX4hD3zaC IYN0b4LclmSSM6A5bOAoACODm0H7Tvvp1i9nHWQzI28bhi8Jylf1pMYA/ammt8dYIC+Z be3wjiTq96VBuJpbYneSMBjVs1HHElnbc+DMqr11mOvogWTsQPV2LTfusKFI/WhOdhq3 P11A== 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=T1nVj3BWOgt2evYTdOqseILrUNzoAtjLuPfGfNtwqRk=; b=emMcj1Q+1bfNs00dnIaNa5PmBnjwUgyCVYG4y3TsGGGOvEXfDJrRHoweroZa9X9p+7 dxR0s+jIGK6HvhbABiZpd/P5e/hIQDSxwv9yjGTfb1bjjPiARGFjNaHJHxtfKVb9GFa7 B/GmT4t6PCAFRpbdF2BHny5d9A90xxfK/KVYhEUYgFsfsAP46m3WcdW5hSJ6m3+559mm z+P3cyFcDredoDUDY66MhqmO0AoFyPNHXlb6m/5hC+eD20klw+G21WXl9je5fcHpH8nW LO5dIZ0nAuVNSVN4poAwnriW1KkrE/F7Us0UlBPs8TBtEEsu0oqQhDTht2S3AEjQD+UV PpiQ== X-Gm-Message-State: ACrzQf3TdzGDpQtwxgwaN0W0Ppoz9BD9KTvXMoQZssQGz11OBDRACtLB c40mgp0SYbAsxw9UKFSbmN3XRw== X-Google-Smtp-Source: AMsMyM74OPvaSUUoozK3S9/I1zM9y3tyUpD3ZnyzCEEQcpjKcU09+WuPUVowEm0iawqTAHtFRdGpOg== X-Received: by 2002:ac2:50d3:0:b0:4a2:9a62:bcb3 with SMTP id h19-20020ac250d3000000b004a29a62bcb3mr20415258lfm.543.1667998759171; Wed, 09 Nov 2022 04:59:19 -0800 (PST) Received: from buamix (86-60-162-79.dynamic.lounea.fi. [86.60.162.79]) by smtp.gmail.com with ESMTPSA id m19-20020a194353000000b004948b667d95sm2208420lfj.265.2022.11.09.04.59.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Nov 2022 04:59:18 -0800 (PST) Date: Wed, 9 Nov 2022 14:59:12 +0200 From: Henri Rosten To: Alyssa Ross Subject: Re: [PATCH] Remove bashisms from spectrum shell scripts Message-ID: <20221109125912.GA931648@buamix> References: <20221108100544.721808-1-henri.rosten@unikie.com> <20221108132727.5ekxh47up5woquoy@x220> <20221108150512.GA833412@buamix> <20221109123210.vxexqshbv7vvrhgg@x220> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221109123210.vxexqshbv7vvrhgg@x220> Message-ID-Hash: BKPL5WYPBZN6ZKY6OIPRLU3L6LKEOXFY X-Message-ID-Hash: BKPL5WYPBZN6ZKY6OIPRLU3L6LKEOXFY 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: RSxv3at2TksS On Wed, Nov 09, 2022 at 12:32:10PM +0000, Alyssa Ross wrote: > > > > @@ -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" > > > > > > The heredoc previously used here should be POSIX: > > > > > > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_07_04 > > > > > > Does it not work in dash? > > > > > > > Heredoc works in dash too, but I couldn't find out how to expand the > > newlines in variable inside heredoc so that it would work in dash. > > Therefore I simply removed the heredoc and used printf instead. > > I think the problem there is this one: > > https://www.shellcheck.net/wiki/SC3003 -- In POSIX sh, $'..' is undefined. > > So I think we could fix it without introducing an extra printf process, > by changing how we define `nl` to use a literal newline. > > The following test script worked for me in dash: > > nl=' > ' > cat < foo${nl}bar > EOF True, that works fine. Let me fix this with a new version in a moment.