Message ID | 20220720063541.5546-1-soeren@soeren-tempel.net |
---|---|
State | New |
Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id AA3943857C44 for <patchwork@sourceware.org>; Wed, 20 Jul 2022 06:36:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AA3943857C44 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1658298982; bh=U2wPRM09hQ2P6vn2DXhM56aNkn1Jb+fMZFW9zDLaAA4=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=RZFppc+Zb0sPdS9p3Wr9gS/8Ngo4HewXVDqhzYlV0GlWWJkHZfNKyKSZUFhibDVhs GEaBzDAtOaZbfNoshkXh8T1sFNs6+KtTFjWprtkYM0gA8LFotDddWE9w1Esh2CtEEw e/d7EUnoOiBMFAh5Nj0PHSwJa06fzE0A0KNd1Su0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from magnesium.8pit.net (magnesium.8pit.net [45.76.88.171]) by sourceware.org (Postfix) with ESMTPS id 8AF973858C62; Wed, 20 Jul 2022 06:35:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 8AF973858C62 Received: from localhost (p200300f5ff05aa004976b5c8ece01b6c.dip0.t-ipconnect.de [2003:f5:ff05:aa00:4976:b5c8:ece0:1b6c]) by magnesium.8pit.net (OpenSMTPD) with ESMTPSA id 73892c48 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:YES); Wed, 20 Jul 2022 08:35:51 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] libgo: make match.sh POSIX-shell compatible Date: Wed, 20 Jul 2022 08:35:41 +0200 Message-Id: <20220720063541.5546-1-soeren@soeren-tempel.net> X-Mailer: git-send-email 2.37.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: soeren--- via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: soeren@soeren-tempel.net Cc: iant@golang.org, gofrontend-dev@googlegroups.com Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
Series |
libgo: make match.sh POSIX-shell compatible
|
|
Commit Message
Li, Pan2 via Gcc-patches
July 20, 2022, 6:35 a.m. UTC
From: Sören Tempel <soeren@soeren-tempel.net> The `(( expression ))` syntax is a Bash extension and not supported by POSIX shell [1]. However, the arithmetic expressions used by the gobuild() function can also be expressed using arithmetic POSIX expansions with `$(( expression ))` [2]. Contrary to the Bash extension, arithmetic expansion doesn't set the return value if the expression is non-zero but instead just prints the expression result. Hence, the expression also needs to be negated. Without this patch, match.sh does currently not work correctly if /bin/sh is not a symlink to Bash. [1]: https://www.gnu.org/software/bash/manual/bash.html#Conditional-Constructs [2]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_04 Signed-off-by: Sören Tempel <soeren@soeren-tempel.net> --- libgo/match.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Tue, Jul 19, 2022 at 11:35 PM <soeren@soeren-tempel.net> wrote: > > From: Sören Tempel <soeren@soeren-tempel.net> > > The `(( expression ))` syntax is a Bash extension and not supported by > POSIX shell [1]. However, the arithmetic expressions used by the > gobuild() function can also be expressed using arithmetic POSIX > expansions with `$(( expression ))` [2]. > > Contrary to the Bash extension, arithmetic expansion doesn't set > the return value if the expression is non-zero but instead just prints > the expression result. Hence, the expression also needs to be negated. > Without this patch, match.sh does currently not work correctly if > /bin/sh is not a symlink to Bash. > > [1]: https://www.gnu.org/software/bash/manual/bash.html#Conditional-Constructs > [2]: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_04 Thanks. Committed as follows, which also fixes the similar function in the gotest script. Ian dbf607d2e92cbae9a7f7620b69b9272adbce6381 diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 5ea0406cd8e..2f2fafde1f1 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -ff68b1a147eb60082fd60c198db0ef5477ade938 +a62f20ae78ddd41be682dde8cab075ca4f5dbb2a The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/libgo/match.sh b/libgo/match.sh index 7ed587ff794..e5ed98de422 100755 --- a/libgo/match.sh +++ b/libgo/match.sh @@ -111,7 +111,7 @@ gobuild() { if test "$goarch" != "386"; then line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g") fi - (($line)) + return $((!($line))) } matched= diff --git a/libgo/testsuite/gotest b/libgo/testsuite/gotest index 04e4267fbba..0a0a7e14d74 100755 --- a/libgo/testsuite/gotest +++ b/libgo/testsuite/gotest @@ -302,7 +302,7 @@ gobuild() { if test "$goarch" != "386"; then line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g") fi - (($line)) + return $((!($line))) } case "x$gofiles" in
diff --git a/libgo/match.sh b/libgo/match.sh index 7ed587ff794..9fbb498544c 100755 --- a/libgo/match.sh +++ b/libgo/match.sh @@ -111,7 +111,7 @@ gobuild() { if test "$goarch" != "386"; then line=$(echo "$line" | sed -e "s/\\(${wrap}\\)386\\(${wrap}\\)/\10\2/g") fi - (($line)) + return $((!(line))) } matched=