Re: git rebase regression: cannot pass a shell expression directly to --exec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 16, 2017 at 10:29:31AM -0700, Eric Rannaud wrote:

> > It does not really work that way. Git runs in a separate process that
> > does not have access to your current shell. That's why you need to do
> > 'export -f foo'.
> >
> > If you want git to be able to ecute the foo shell function, git needs to
> > start a _new_ shell process, which reads the environment, recognize the
> > exported function and run that.
> >
> > This is not the same as git executing the command in your shell. Not
> > exported variables would not be available in this function (as it would
> > be in your equivalent).
> 
> I'm sorry, I didn't mean (or say) "my shell process". Indeed, it
> doesn't work that way. And to be clear, there is no problem with
> having to "export -f foo". The only question is how should git run the
> <cmd> passed to --exec: should it run directly or using a shell?

It's definitely "using a shell". Most things Git runs on your behalf
behave the same, but there are some exceptions due to historical warts
(that would break backwards compatibility if we switched them). E.g.,
$GIT_SSH does not use the shell, but we introduced GIT_SSH_COMMAND as an
alternative which does use the shell.

But note that "a shell" may not be necessarily be your login shell. We
always execute "/bin/sh -c" (and you can override the shell path at
build time). So your "export -f" trick only works because your /bin/sh
is a symlink to bash (or because you specifically built with the
SHELL_PATH knob pointed at bash).

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]