git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "Martin Ågren" <martin.agren@gmail.com>
Cc: git@vger.kernel.org, "Alexander Pyhalov" <apyhalov@gmail.com>,
	"SZEDER Gábor" <szeder.dev@gmail.com>,
	"Eric Sunshine" <sunshine@sunshineco.com>
Subject: Re: [PATCH] t7005-editor: quote filename to fix whitespace-issue
Date: Wed, 26 Sep 2018 15:21:09 -0400	[thread overview]
Message-ID: <20180926192109.GE30680@sigill.intra.peff.net> (raw)
In-Reply-To: <20180926161411.10697-1-martin.agren@gmail.com>

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

  parent reply	other threads:[~2018-09-26 19:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26  6:52 t7005-editor.sh failure Alexander Pyhalov
2018-09-26  7:59 ` Martin Ågren
2018-09-26  9:00   ` Alexander Pyhalov
2018-09-26  9:52     ` Martin Ågren
2018-09-26 10:02       ` Alexander Pyhalov
2018-09-26 11:59       ` Eric Sunshine
2018-09-26 13:23         ` Martin Ågren
2018-09-26 12:11       ` SZEDER Gábor
2018-09-26 16:14         ` [PATCH] t7005-editor: quote filename to fix whitespace-issue Martin Ågren
2018-09-26 18:14           ` Taylor Blau
2018-09-26 19:21           ` Jeff King [this message]
2018-09-26 18:16         ` t7005-editor.sh failure Junio C Hamano
2018-09-26 19:16           ` Junio C Hamano
2018-09-26 19:29             ` Andrei Rybak
2018-09-27 20:53             ` SZEDER Gábor

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180926192109.GE30680@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=apyhalov@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=martin.agren@gmail.com \
    --cc=sunshine@sunshineco.com \
    --cc=szeder.dev@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).