On Wed, Sep 26, 2018 at 06:14:11PM +0200, Martin Ågren wrote:
> diff --git a/t/t7005-editor.sh b/t/t7005-editor.sh
> index b2ca77b338..5fcf281dfb 100755
> --- a/t/t7005-editor.sh
> +++ b/t/t7005-editor.sh
> @@ -112,7 +112,7 @@ do
> done
>
> test_expect_success 'editor with a space' '
> - echo "echo space >\$1" >"e space.sh" &&
> + echo "echo space >\"\$1\"" >"e space.sh" &&
> chmod a+x "e space.sh" &&
> GIT_EDITOR="./e\ space.sh" git commit --amend &&
I was actually puzzled how SHELL_PATH matters here at all, since the
resulting script does not mention it.
What happens is that we first try to execve("./e space.sh"), can get
ENOEXEC. And then we resort to passing it to the shell, which then uses
historical shell magic (which apparently predates the invention of #!
entirely!) to decide to run it as a script using the current shell. And
that shell is selected via the SHELL_PATH at build time (and not the
$SHELL_PATH we have in our environment here).
So I think this fix and the explanation are correct. I do think it would
be a lot less subtle (and a lot more readable) as:
write_script "e space.sh" <<-\EOF &&
echo space >"$1"
EOF
but that is orthogonal to what you're fixing.
-Peff