From patchwork Wed Jul 20 06:35:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Li, Pan2 via Gcc-patches" X-Patchwork-Id: 56187 Return-Path: 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 ; 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: soeren--- via Gcc-patches From: "Li, Pan2 via Gcc-patches" 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" From: Sören Tempel 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 --- libgo/match.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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=