Re: couple questions about git "logical variables" and "git var"
- From
Jeff King <peff@peff.net>
- Date
- Oct 6, 2017, 04:33 UTC
- Message-ID
- <20171006043300.to2d2zv6ludbinrh@sigill.intra.peff.net>
- In-Reply-To
- <20171006023530.GA134987@aiede.mtv.corp.google.com>
On Thu, Oct 05, 2017 at 07:35:30PM -0700, Jonathan Nieder wrote:
Show 13 quoted lines
> > It also only tells half the story. You have to know not just what's in > > $GIT_EDITOR, but you have to know the right way to evaluate it. There's > > a git_editor helper in git-sh-setup, but other scripting languages are > > on their own. > > I am not sure I understand the complaint here. git-var(1) says: > > GIT_EDITOR > Text editor for use by Git commands. The value is meant to be > interpreted by the shell when it is used. Examples: [...] > > Are you saying that the output of the command should quote that > manpage, so as to tell the rest of the story?
No, I just meant that after reading that manpage, I'm not sure I would have picked up the subtlety that shell scripts need to call:
eval "$GIT_EDITOR" '"$@"'
and not:
"$GIT_EDITOR" "$@"
or:
$GIT_EDITOR "$@"
(And likewise, other languages need to make sure they run "sh -c ..." and not a straight spawn/exec of the editor command).
If the command were instead:
git editor "$@"
that's harder to get wrong.
-Peff