git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] t7005-editor: quote filename to fix whitespace-issue

From
Jeff King <peff@peff.net>
Date
Sep 26, 2018, 19:21 UTC
Message-ID
<20180926192109.GE30680@sigill.intra.peff.net>
In-Reply-To
<20180926161411.10697-1-martin.agren@gmail.com>
On Wed, Sep 26, 2018 at 06:14:11PM +0200, Martin Ågren wrote:
Show 12 quoted lines
> 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
Previous: Taylor BlauNext: Junio C Hamano
Message 11 of 15 in “t7005-editor.sh failure”
  1. Alexander PyhalovSep 26, 2018
  2. Martin ÅgrenSep 26, 2018
  3. Alexander PyhalovSep 26, 2018
  4. Martin ÅgrenSep 26, 2018
  5. Alexander PyhalovSep 26, 2018
  6. Eric SunshineSep 26, 2018
  7. Martin ÅgrenSep 26, 2018
  8. SZEDER GáborSep 26, 2018
  9. t7005-editor: quote filename to fix whitespace-issueMartin Ågren, Sep 26, 2018
  10. Taylor BlauSep 26, 2018
  11. Jeff KingSep 26, 2018
  12. Junio C HamanoSep 26, 2018
  13. Junio C HamanoSep 26, 2018
  14. Andrei RybakSep 26, 2018
  15. SZEDER GáborSep 27, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.