public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Jonathan Wakely <redi@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r12-7588] contrib: Fix non-portable shell commands in gcc-git-customization.sh [PR102664]
Date: Thu, 10 Mar 2022 11:49:31 +0000 (GMT)	[thread overview]
Message-ID: <20220310114931.1B1363858C20@sourceware.org> (raw)

https://gcc.gnu.org/g:d563b0bff19c31eb755c026ee990bca986683f25

commit r12-7588-gd563b0bff19c31eb755c026ee990bca986683f25
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Mar 9 14:53:52 2022 +0000

    contrib: Fix non-portable shell commands in gcc-git-customization.sh [PR102664]
    
    Use printf instead of echo -n. Use Basic Regular Expressions instead of
    sed -r. Check for error from ancient Git versions that don't support the
    --git-path option for git-rev-parse. Remove -c flag from install
    command, as it's ignored by GNU and BSD install, but means something
    different for Solaris and AIX.
    
    contrib/ChangeLog:
    
            PR other/102664
            * gcc-git-customization.sh: Fix non-portable commands.

Diff:
---
 contrib/gcc-git-customization.sh | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/contrib/gcc-git-customization.sh b/contrib/gcc-git-customization.sh
index b24948d9874..914d868f7bd 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 [%s]? " "$question" "$default"
     read answer
     if [ "x$answer" = "x" ]
     then
@@ -110,7 +110,7 @@ then
 	# This is a pure guess, but for many people it might be OK.
 	remote_id=$(whoami)
     else
-	remote_id=$(echo $url | sed -r "s|^.*ssh://(.+)@gcc.gnu.org.*$|\1|")
+	remote_id=$(echo $url | sed 's|^.*ssh://\(..*\)@gcc.gnu.org.*$|\1|')
 	if [ x$remote_id = x$url ]
 	then
 	    remote_id=$(whoami)
@@ -118,7 +118,7 @@ then
     fi
 fi
 
-ask "Account name on gcc.gnu.org (for your personal branches area)" $remote_id remote_id
+ask "Account name on gcc.gnu.org (for your personal branches area)" "$remote_id" remote_id
 git config "gcc-config.user" "$remote_id"
 
 old_pfx=$(git config --get "gcc-config.userpfx")
@@ -135,16 +135,20 @@ git config "gcc-config.userpfx" "$new_pfx"
 echo
 ask "Install prepare-commit-msg git hook for 'git commit-mklog' alias" yes dohook
 if [ "x$dohook" = xyes ]; then
-    hookdir=`git rev-parse --git-path hooks`
-    if [ -f "$hookdir/prepare-commit-msg" ]; then
-	echo " Moving existing prepare-commit-msg hook to prepare-commit-msg.bak"
-	mv "$hookdir/prepare-commit-msg" "$hookdir/prepare-commit-msg.bak"
+    hookdir=`git rev-parse --git-path hooks 2>/dev/null`
+    if [ $? -eq 0 ]; then
+	if [ -f "$hookdir/prepare-commit-msg" ]; then
+	    echo " Moving existing prepare-commit-msg hook to prepare-commit-msg.bak"
+	    mv "$hookdir/prepare-commit-msg" "$hookdir/prepare-commit-msg.bak"
+	fi
+	install -c "`git rev-parse --show-toplevel`/contrib/prepare-commit-msg" "$hookdir"
+    else
+	echo " `git --version` is too old, cannot find hooks dir"
     fi
-    install -c "`git rev-parse --show-toplevel`/contrib/prepare-commit-msg" "$hookdir"
 fi
 
 # Scan the existing settings to see if there are any we need to rewrite.
-vendors=$(git config --get-all "remote.${upstream}.fetch" "refs/vendors/" | sed -r "s:.*refs/vendors/([^/]+)/.*:\1:" | sort | uniq)
+vendors=$(git config --get-all "remote.${upstream}.fetch" "refs/vendors/" | sed 's:.*refs/vendors/\([^/][^/]*\)/.*:\1:' | sort | uniq)
 url=$(git config --get "remote.${upstream}.url")
 pushurl=$(git config --get "remote.${upstream}.pushurl")
 for v in $vendors


                 reply	other threads:[~2022-03-10 11:49 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220310114931.1B1363858C20@sourceware.org \
    --to=redi@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).