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

Re: [PATCH 1/2] test-lib: quote TRASH_DIRECTORY

From
Jeff King <peff@peff.net>
Date
Mar 4, 2016, 13:09 UTC
Message-ID
<20160304130939.GA15375@sigill.intra.peff.net>
In-Reply-To
<56D98793.9000708@drmicha.warpmail.net>
On Fri, Mar 04, 2016 at 02:03:15PM +0100, Michael J Gruber wrote:
Show 18 quoted lines
> >> -test ! -z "$debug" || remove_trash=$TRASH_DIRECTORY
> >> +test ! -z "$debug" || remove_trash="$TRASH_DIRECTORY"
> > 
> > I don't think this does anything. The shell doesn't do whitespace
> > splitting on the right-hand side of a variable assignment:
> > 
> >   $ foo='lots of spaces and "!'\'' funky chars'
> >   $ bar=$foo
> >   $ echo "$bar"
> >   lots of spaces and "!' funky chars
> > 
> > Of course we _do_ need quotes when we refer to $remove_trash as an
> > argument (as with "$bar" above), but it looks like we do so correctly
> > everywhere.
> 
> I'm used to that behavior, yes, but:
> 
> - Is this true for every shell that we support?
It better be, because we rely on it all through our scripts. :)

But yes, it is in POSIX, and I think any shell which did not respect it would be broken enough to be unusable (I don't have a copy of Solaris /bin/sh handy, but that's usually our go-to for "unusably broken").

> - Having quotes there, too, is a good reminder to have it also where
> necessary.

We do already quote variable assignments unnecessarily in lots of places, so I don't mind it too much (it's definitely not _wrong_ to do so).

-Peff
Previous: Michael J GruberNext: Michael J Gruber
Message 5 of 9 in “Test trash dir sanitizing”
  1. 0/2 Test trash dir sanitizingMichael J Gruber, Mar 4, 2016
  2. 1/2 test-lib: quote TRASH_DIRECTORYMichael J Gruber, Mar 4, 2016
  3. Jeff KingMar 4, 2016
  4. Michael J GruberMar 4, 2016
  5. Jeff KingMar 4, 2016
  6. 2/2 t5510: do not leave changed cwdMichael J Gruber, Mar 4, 2016
  7. Jeff KingMar 4, 2016
  8. Michael J GruberMar 4, 2016
  9. Junio C HamanoMar 4, 2016

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.