Message ID | fea9431c-e183-53a8-c883-1bfb31ecf1d2@foss.arm.com |
---|---|
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 CBCCE385780C for <patchwork@sourceware.org>; Wed, 9 Mar 2022 12:15:54 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CBCCE385780C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1646828154; bh=c8W9TDy/IkqrLEDJL0dvUHsJpLtg2zXk5I57REm/hfs=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=aH4vziTyq88zKn3Dht9BhWBkaJbSvT+R9RNeMCY9gdjCk+JEomnNDJnRQvi4SI8rz NmggYhr2DlAUewVy7E2xzV79TZD1H3/m7Gdi5JV6E35FCp5CqrQKLjcfnWFwseCn/T dF7M5a3eEGtKGcCmaTSWELyYl0jTwk0as1mJdC38= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id 7AF5E3858D28 for <gcc-patches@gcc.gnu.org>; Wed, 9 Mar 2022 12:15:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 7AF5E3858D28 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0F8771688 for <gcc-patches@gcc.gnu.org>; Wed, 9 Mar 2022 04:15:25 -0800 (PST) Received: from [10.57.21.174] (unknown [10.57.21.174]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A3E1D3FA4D; Wed, 9 Mar 2022 04:15:24 -0800 (PST) Content-Type: multipart/mixed; boundary="------------lV0Lk0IUI1qxrYzAwcMR3Snt" Message-ID: <fea9431c-e183-53a8-c883-1bfb31ecf1d2@foss.arm.com> Date: Wed, 9 Mar 2022 12:15:21 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Content-Language: en-GB To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org> Subject: [PATCH] contrib: Avoid use of "echo -n" in git customization [PR102664] X-Spam-Status: No, score=-3497.1 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Richard Earnshaw via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Richard Earnshaw <Richard.Earnshaw@foss.arm.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 |
contrib: Avoid use of "echo -n" in git customization [PR102664]
|
|
Commit Message
Richard Earnshaw
March 9, 2022, 12:15 p.m. UTC
The -n option to echo is non-portable. The generally recommended alternative is to use the shell printf command. contrib/ChangeLog: PR other/102664 * gcc-git-customization.sh (ask): Use printf instead of echo -n.
Comments
On 09/03/22 12:15 +0000, Richard Earnshaw wrote: >The -n option to echo is non-portable. The generally recommended >alternative is to use the shell printf command. > >contrib/ChangeLog: > > PR other/102664 > * gcc-git-customization.sh (ask): Use printf instead of echo -n. > >diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh >index b24948d9874..cf46c494a6a 100755 >--- a/contrib/gcc-git-customization.sh >+++ b/contrib/gcc-git-customization.sh >@@ -7,7 +7,7 @@ ask () { > question=$1 > default=$2 > var=$3 >- echo -n $question "["$default"]? " >+ printf "%s" "$question [$default]? " > read answer > if [ "x$answer" = "x" ] > then This isn't enough to get the script working on AIX and Solaris. The attached patch has been tested on Fedora Linux, NetBSD 9.2, AIX 7 and Solaris 11. The part checking the result of `git rev-parse --git-path hooks` was needed to work around Git 2.4.0 on gcc211 in the compile farm, which is a Solaris 11 sparc box. That's a truly ancient version, but handling the error (and just skipping installation of the hook) isn't difficult, so seems worthwhile. I can revert that part if preferred. OK for trunk?
On 09/03/2022 15:05, Jonathan Wakely via Gcc-patches wrote: > On 09/03/22 12:15 +0000, Richard Earnshaw wrote: >> The -n option to echo is non-portable. The generally recommended >> alternative is to use the shell printf command. >> >> contrib/ChangeLog: >> >> PR other/102664 >> * gcc-git-customization.sh (ask): Use printf instead of echo -n. >> >> diff --git a/contrib/gcc-git-customization.sh >> b/contrib/gcc-git-customization.sh >> index b24948d9874..cf46c494a6a 100755 >> --- a/contrib/gcc-git-customization.sh >> +++ b/contrib/gcc-git-customization.sh >> @@ -7,7 +7,7 @@ ask () { >> question=$1 >> default=$2 >> var=$3 >> - echo -n $question "["$default"]? " >> + printf "%s" "$question [$default]? " >> read answer >> if [ "x$answer" = "x" ] >> then > > This isn't enough to get the script working on AIX and Solaris. The > attached patch has been tested on Fedora Linux, NetBSD 9.2, AIX 7 and > Solaris 11. > > The part checking the result of `git rev-parse --git-path hooks` was > needed to work around Git 2.4.0 on gcc211 in the compile farm, which > is a Solaris 11 sparc box. That's a truly ancient version, but > handling the error (and just skipping installation of the hook) isn't > difficult, so seems worthwhile. I can revert that part if preferred. > > OK for trunk? > > OK.
diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh index b24948d9874..cf46c494a6a 100755 --- a/contrib/gcc-git-customization.sh +++ b/contrib/gcc-git-customization.sh @@ -7,7 +7,7 @@ ask () { question=$1 default=$2 var=$3 - echo -n $question "["$default"]? " + printf "%s" "$question [$default]? " read answer if [ "x$answer" = "x" ] then