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

Re: t3404 static check of bad SHA-1 failure

From
Jeff King <peff@peff.net>
Date
May 13, 2016, 20:02 UTC
Message-ID
<20160513200232.GA10371@sigill.intra.peff.net>
In-Reply-To
<20160513195911.GE9890@sigill.intra.peff.net>
On Fri, May 13, 2016 at 03:59:11PM -0400, Jeff King wrote:
Show 33 quoted lines
> On Fri, May 13, 2016 at 12:52:44PM -0700, Junio C Hamano wrote:
> 
> > I _think_ "test -z" should succeed according to POSIX, because
> > 
> >  (1) it is not "test -z string" because it lacks string,
> > 
> >  (2) it is not any of the other "test -<option> thing" because -z,
> >     and
> > 
> >  (3) the only thing it matches in the supported form of "test" is
> >      "test <string>" that tests if the <string> is not the null
> >      string, and "-z" indeed is not the null string.
> > 
> > For the same reason, "test -n" succeeds.
> 
> Yeah, I think you're right; POSIX is pretty clear that this falls under
> case 3. So that means "test -z" quietly does what we want. But it means
> that "test -n" does the _opposite_ of what we want.
> 
> And sadly,
> 
>   git grep 'test -n [^"]'
> 
> is not empty.
> 
> > But working around older/broken shells is easy and the resulting
> > script it more readable, so let's take this.  It makes the resulting
> > code easier to understand even when we know we run it under POSIX
> > shell.
> 
> Yep. The POSIX-explanation of what is going on might be worth putting in
> the commit message for the "-z" case (i.e., it should work, but the
> "why" is subtle).

I think we can just lump all of these into a single patch, but there are a few related cleanups, including the SVN stuff I just sent. So let me send out a unified patch series in a moment.

-Peff
Previous: Jeff KingNext: Junio C Hamano
Message 5 of 19 in “t3404 static check of bad SHA-1 failure”
  1. Armin KunaschikMay 13, 2016
  2. Jeff KingMay 13, 2016
  3. Junio C HamanoMay 13, 2016
  4. Jeff KingMay 13, 2016
  5. Jeff KingMay 13, 2016
  6. Junio C HamanoMay 13, 2016
  7. 0/6 test -z/-n quoting fix + misc cleanupsJeff King, May 13, 2016
  8. 1/6 t/lib-git-svn: drop $remote_git_svn and $git_svn_idJeff King, May 13, 2016
  9. 2/6 t9100,t3419: enclose all test code in single-quotesJeff King, May 13, 2016
  10. 3/6 t9107: use "return 1" instead of "exit 1"Jeff King, May 13, 2016
  11. Eric WongMay 13, 2016
  12. Eric SunshineMay 13, 2016
  13. Jeff KingMay 13, 2016
  14. Junio C HamanoMay 14, 2016
  15. Jeff KingMay 14, 2016
  16. 4/6 t9107: switch inverted single/double quotes in testJeff King, May 13, 2016
  17. 5/6 t9103: modernize test styleJeff King, May 13, 2016
  18. 6/6 always quote shell arguments to test -z/-nJeff King, May 13, 2016
  19. Junio C HamanoMay 13, 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.