On Thu, Oct 05, 2017 at 07:35:30PM -0700, Jonathan Nieder wrote:

> > 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

Reply via email to