git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-sh-setup: fix parseopt `eval`.
@ 2007-11-08  7:09 Junio C Hamano
  2007-11-08  8:15 ` Pierre Habouzit
  2007-11-08  9:14 ` Pierre Habouzit
  0 siblings, 2 replies; 4+ messages in thread
From: Junio C Hamano @ 2007-11-08  7:09 UTC (permalink / raw)
  To: Pierre Habouzit; +Cc: git

The 'automagic parseopt' support corrupted non option parameters
that had IFS characters in them.  The worst case can be seen
when it has a non option parameter like this:

	$1=" * some string   blech"

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---

 * I had "git pull -n . to/pic-branch" in Meta/PU which was
   affected by this bug, expanding the " * " bullet before the
   merge message that is passed from git-pull to git-merge.

   I am a bit upset because I _knew_ that the eval was wrong
   when I first saw it, but somehow I forgot about it when I
   made it land on 'next'.  My fault.

 git-sh-setup.sh |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index e1cf885..f1c4839 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -21,11 +21,12 @@ if test -n "$OPTIONS_SPEC"; then
 		exec "$0" -h
 	}
 
-	parseopt_extra=
-	[ -n "$OPTIONS_KEEPDASHDASH" ] &&
-		parseopt_extra="$parseopt_extra --keep-dashdash"
-
-	eval `echo "$OPTIONS_SPEC" | git rev-parse --parseopt $parseopt_extra -- "$@" || echo exit $?`
+	[ -n "$OPTIONS_KEEPDASHDASH" ] && parseopt_extra="--keep-dashdash"
+	parsed=$(
+		echo "$OPTIONS_SPEC" |
+		git rev-parse --parseopt $parseopt_extra -- "$@"
+	) &&
+	eval "$parsed" || exit
 else
 	usage() {
 		die "Usage: $0 $USAGE"
-- 
1.5.3.5.1617.g65b5b

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2007-11-08  9:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-08  7:09 [PATCH] git-sh-setup: fix parseopt `eval` Junio C Hamano
2007-11-08  8:15 ` Pierre Habouzit
2007-11-08  9:14 ` Pierre Habouzit
2007-11-08  9:35   ` Pierre Habouzit

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 NNTP newsgroup(s).