git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-sh-setup: fix parseopt `eval`.

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 8, 2007, 07:09 UTC
Message-ID
<7vr6j15i3a.fsf@gitster.siamese.dyndns.org>

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
Next: Pierre Habouzit
Message 1 of 4 in “git-sh-setup: fix parseopt `eval`.”
  1. git-sh-setup: fix parseopt `eval`.Junio C Hamano, Nov 8, 2007
  2. Pierre HabouzitNov 8, 2007
  3. Pierre HabouzitNov 8, 2007
  4. Pierre HabouzitNov 8, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.