Git development
 help / color / mirror / Atom feed
From: Junio C Hamano <junkio@cox.net>
To: git@vger.kernel.org
Cc: Mark Wooding <mdw@distorted.org.uk>
Subject: [PATCH] Fix-up previous expr changes.
Date: Thu, 13 Apr 2006 19:12:24 -0700	[thread overview]
Message-ID: <7v8xq8x5vb.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: <slrne3tihk.1dq.mdw@metalzone.distorted.org.uk> (Mark Wooding's message of "Thu, 13 Apr 2006 22:01:24 +0000 (UTC)")

The regexp on the right hand side of expr : operator somehow was
broken.

	expr 'z+pu:refs/tags/ko-pu' : 'z\+\(.*\)'

does not strip '+'; write 'z+\(.*\)' instead.

We probably should switch to shell based substring post 1.3.0;
that's not bashism but just POSIX anyway.

Signed-off-by: Junio C Hamano <junkio@cox.net>

---

 * Funny thing is that before the z prefixing, the code was
   already broken (we said expr "$ref" : '\+\(.*\)'), but
   somehow it worked.  It could be a bug in expr.

	# already buggy but did not trigger somehow.
        : siamese; expr '+pu:ko-pu' : '\+\(.*\)'
        pu:ko-pu
        # z prefix exposed the breakage.
        : siamese; expr 'z+pu:ko-pu' : 'z\+\(.*\)'
        +pu:ko-pu
        # the fix-up this patch is about.
        : siamese; expr 'z+pu:ko-pu' : 'z+\(.*\)'
        pu:ko-pu
        # this is the way it should have been written from the start.
        : siamese; expr '+pu:ko-pu' : '+\(.*\)'
        pu:ko-pu
        # maybe I am using broken expr...
        : siamese; type expr
        expr is hashed (/usr/bin/expr)
        : siamese; /usr/bin/expr --version |head -n2
        expr (GNU coreutils) 5.94
        Copyright (C) 2006 Free Software Foundation, Inc.

 git-fetch.sh        |    4 ++--
 git-parse-remote.sh |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

dfdcb558ecf93c0e09b8dab89cff4839e8c95e36
diff --git a/git-fetch.sh b/git-fetch.sh
index 711650f..83143f8 100755
--- a/git-fetch.sh
+++ b/git-fetch.sh
@@ -252,10 +252,10 @@ fetch_main () {
       else
 	  not_for_merge=
       fi
-      if expr "z$ref" : 'z\+' >/dev/null
+      if expr "z$ref" : 'z+' >/dev/null
       then
 	  single_force=t
-	  ref=$(expr "z$ref" : 'z\+\(.*\)')
+	  ref=$(expr "z$ref" : 'z+\(.*\)')
       else
 	  single_force=
       fi
diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 65c66d5..c9b899e 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -77,7 +77,7 @@ canon_refs_list_for_fetch () {
 		force=
 		case "$ref" in
 		+*)
-			ref=$(expr "z$ref" : 'z\+\(.*\)')
+			ref=$(expr "z$ref" : 'z+\(.*\)')
 			force=+
 			;;
 		esac
-- 
1.3.0.rc3.gce03

      parent reply	other threads:[~2006-04-14  2:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-13 22:01 [PATCH] Shell utilities: Guard against expr' magic tokens Mark Wooding
2006-04-13 23:39 ` Junio C Hamano
2006-04-14  2:12 ` Junio C Hamano [this message]

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=7v8xq8x5vb.fsf@assigned-by-dhcp.cox.net \
    --to=junkio@cox.net \
    --cc=git@vger.kernel.org \
    --cc=mdw@distorted.org.uk \
    /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