From: Thomas Rast <trast@student.ethz.ch>
To: Joshua Jensen <jjensen@workspacewhiz.com>,
Avery Pennarun <apenwarr@gmail.com>
Cc: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
Giuseppe Scrivano <gscrivano@gnu.org>,
"git@vger.kernel.org" <git@vger.kernel.org>,
<msysgit@googlegroups.com>
Subject: Re: [msysGit] git rev-parse broken on Git for Windows
Date: Fri, 30 Jul 2010 16:43:50 +0200 [thread overview]
Message-ID: <201007301643.50730.trast@student.ethz.ch> (raw)
In-Reply-To: <4C52E125.1020004@workspacewhiz.com>
Joshua Jensen wrote:
> Thomas Rast wrote:
> > Johannes Schindelin wrote:
> >>> eval $(echo "$OPTS_SPEC" | git rev-parse --parseopt -- "$@" || echo exit $?)
> > Can you elaborate on "break"?
> >
> > Because as you can see in git-sh-setup.sh, the "official" user of
> > parseopt does
> >
> > eval "$(
> > echo "$OPTIONS_SPEC" |
> > git rev-parse --parseopt $parseopt_extra -- "$@" ||
> > echo exit $?
> > )"
> >
> > So AFAICS they only differ in the quoting. And the latter works.
> Here is the output from Git Bash:
>
> $ git subtree
> C:\Program Files (x86)\Git/libexec/git-core/git-subtree: eval: line 31:
> syntax error near unexpected token `<'
[...]
> The example from the git rev-parse documentation fails in the same way:
>
> eval `echo "$OPTS_SPEC" | git rev-parse --parseopt $parseopt_extra --
> "$@" || echo exit $?`
Oh, sorry that I was so dense in the first reply. Of course the
quoting is the problem. When unquoted, the shell first splits along
whitespace and then eval reassembles with *one space* between each
pair of words. The change just exacerbated the issue; there are other
ways to trigger bad behaviour if the eval uses an unquoted --parseopt:
# what you saw
$ echo eval $( (echo 'description'; echo --; echo "s,long= foo") | git rev-parse --parseopt -- --help || echo exit $?)
eval cat <<\EOF usage: description -s, --long ... foo EOF exit 129
# newlines are clobbered
$ echo eval $( (echo 'description'; echo --; echo "s,long= foo") | git rev-parse --parseopt -- --long="$(printf 'argument\nwith\nnewlines')" || echo exit $?)
eval set -- -s 'argument with newlines' --
# consecutive spaces are also clobbered
echo eval $( (echo 'description'; echo --; echo "s,long= foo") | git rev-parse --parseopt -- --long="three spaces" || echo exit $?)
eval set -- -s 'three spaces' --
So I'm afraid Avery will have to fix this in git-subtree. I'll also
follow up with a doc patch for git-rev-parse. Luckily there are no
users in git outside of tests and git-sh-setup, so there are no bugs.
--
Thomas Rast
trast@{inf,student}.ethz.ch
next prev parent reply other threads:[~2010-07-30 14:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-07-30 5:25 git rev-parse broken on Git for Windows Joshua Jensen
2010-07-30 8:26 ` [msysGit] " Johannes Schindelin
2010-07-30 9:02 ` Thomas Rast
2010-07-30 14:26 ` Joshua Jensen
2010-07-30 14:43 ` Thomas Rast [this message]
2010-07-30 15:01 ` [PATCH] Documentation/rev-parse: quoting is required with --parseopt Thomas Rast
2010-07-30 16:44 ` [msysGit] git rev-parse broken on Git for Windows Junio C Hamano
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=201007301643.50730.trast@student.ethz.ch \
--to=trast@student.ethz.ch \
--cc=Johannes.Schindelin@gmx.de \
--cc=apenwarr@gmail.com \
--cc=git@vger.kernel.org \
--cc=gscrivano@gnu.org \
--cc=jjensen@workspacewhiz.com \
--cc=msysgit@googlegroups.com \
/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 NNTP newsgroup(s).