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

Re: [PATCH 1/4] test: Add target test-lint-shell-syntax

From
Jeff King <peff@peff.net>
Date
Jan 2, 2013, 23:22 UTC
Message-ID
<20130102232239.GA27952@sigill.intra.peff.net>
In-Reply-To
<50E4BF58.4090808@web.de>
On Thu, Jan 03, 2013 at 12:14:32AM +0100, Torsten Bögershausen wrote:
Show 8 quoted lines
> > This is wrong if $(PERL_PATH) contains spaces, no? Doing "$(PERL_PATH)"
> > is also wrong, because the expansion happens in 'make', and a
> > $(PERL_PATH) with double-quotes would fool the shell. Since we export
> > $PERL_PATH, I think doing:
> > 
> >   "$$PERL_PATH"" check-non-portable-shell.pl $(T)
> Thanks, but:             
> - The double "" after PERL_PATH makes the string un-terminated.
Yeah, sorry, typo on my part.
> - Using "$$PERL_PATH" expands from make into "$PERL_PATH" on the command line
Right. That's what I intended.
Show 8 quoted lines
> - If the Makefile looks like this:
> PERL_PATH = "/Users/tb/projects/git/tb/pe rl"
> [snip]
> $(PERL_PATH) check-non-portable-shell.pl $(T)
> The command line will look like this:
> "/Users/tb/projects/git/tb/pe rl" check-non-portable-shell.pl t0000-basic.sh ...
> 
> So I think that PERL_PATH should be quoted when it is defined in the Makefile.
Does a $PERL_PATH with quotes actually work?

Usually in our runtime environment, commands that are handed to git are assumed to be passed directly to the shell, and you need to quote. E.g., setting diff.external to:

  [diff]
  external = "foo --bar"

will let the shell split the argument out; if you have a space, you would want to set it like:

  [diff]
  external = "'command with space'"
This is the most flexible way to do it.

However, for Makefile variables, I think we do not (and cannot) follow the same rule. Notice that all of the uses of $PERL_PATH in the test suite enclose it in quotes. Having extra quotes would break those invocations. And the value of $PERL_PATH will be put on the #!-line, which cannot not be quoted.

-Peff
Previous: Torsten BögershausenNext: Torsten Bögershausen
Message 8 of 18 in “test: Add target test-lint-shell-syntax”
  1. 1/4 test: Add target test-lint-shell-syntaxTorsten Bögershausen, Jan 1, 2013
  2. Junio C HamanoJan 1, 2013
  3. Torsten BögershausenJan 2, 2013
  4. Junio C HamanoJan 2, 2013
  5. Jeff KingJan 2, 2013
  6. Junio C HamanoJan 2, 2013
  7. Torsten BögershausenJan 2, 2013
  8. Jeff KingJan 2, 2013
  9. Torsten BögershausenJan 2, 2013
  10. Junio C HamanoJan 3, 2013
  11. Torsten BögershausenJan 3, 2013
  12. Junio C HamanoJan 3, 2013
  13. tests: turn on test-lint by defaultJeff King, Jan 3, 2013
  14. Junio C HamanoJan 3, 2013
  15. Junio C HamanoJan 3, 2013
  16. Torsten BögershausenJan 7, 2013
  17. Junio C HamanoJan 7, 2013
  18. Torsten BögershausenJan 8, 2013

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.