Re: git rebase regression: cannot pass a shell expression directly to --exec
- From
- Eric Rannaud <eric.rannaud@gmail.com>
- Date
- May 16, 2017, 17:21 UTC
- Message-ID
- <CA+zRj8XLQiTmiVbsJZ7XjdW4bQvMSJpCtKW8xx5JvMKOhBDmLQ@mail.gmail.com>
- In-Reply-To
- <CA+zRj8Uxh1SGdVW=zz29Q4m4OnDcs665T0XtV6FiZ_qZSiG-8g@mail.gmail.com>
On Tue, May 16, 2017 at 9:59 AM, Eric Rannaud <eric.rannaud@gmail.com> wrote:
Show 5 quoted lines
> When I use "git rebase --exec <cmd>" I'm basically writing a "foreach
> commit in range { <cmd> }" in my shell. Same idea with git bisect run.
>
> A transparent optimization that tries execve() then falls back to the
> user's shell sounds like a good idea.One issue with the execve-else-shell optimization is that sometimes a binary exists that will shadow an exported function or a shell builtin:
git rebase --exec true master^^ # OK but in fact this runs /usr/bin/true
In this case it doesn't really matter. If the optimization is only applied to "simple commands" (i.e. no arguments), then it's probably OK. I can't think of problematic cases. Except weird things like:
$ git rebase --exec time master^
Executing: time
Usage: time [-apvV] [-f format] [-o file] [--append] [--verbose]
[--portability] [--format=format] [--output=file] [--version]
[--help] command [arg...]
warning: execution failed: time/usr/bin/time requires an argument. Even though the bash builtin time runs fine without argument.
$ time
real 0m0.000s user 0m0.000s sys 0m0.000s
But if the optimization is applied to more complex commands, then we will have problems. For instance, the builtin echo supports \E, but /usr/bin/echo doesn't support it.
In any case, the manpage says --exec <cmd> and "<cmd> will be interpreted as one or more shell commands.", it doesn't say "--exec <executable>".