git-sh-setup: fix parseopt `eval` string underquoting
authorJunio C Hamano <gitster@pobox.com>
Thu, 8 Nov 2007 07:04:38 +0000 (23:04 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Nov 2007 07:10:10 +0000 (23:10 -0800)
The 'automagic parseopt' support corrupted non option parameters
that had IFS characters in them.  The worst case is when it had
a non option parameter like this:

$1=" * some string"

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

index e1cf885983f60c66472ccfa3c4b9e66b60255866..f1c4839a9fe2883f1106d9f9ee209fe4b53b3720 100755 (executable)
@@ -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"