From: Junio C Hamano Date: Fri, 13 May 2016 19:52:44 GMT Subject: Re: t3404 static check of bad SHA-1 failure Message-ID: In-Reply-To: <20160513182325.GB30700@sigill.intra.peff.net> Jeff King writes: > On Fri, May 13, 2016 at 06:09:35PM +0200, Armin Kunaschik wrote: > >> in t3404 test 91 - static check of bad SHA-1 fails (with ksh) with a >> syntax error in git-rebase. >> git-rebase[6]: test: argument expected > > Here's a fix that covers these and another I found: > > -- >8 -- > Subject: [PATCH] always quote arguments to "test -z" in shell > > Modern shells are pretty forgiving about us doing: > > test -z $foo > > If $foo is indeed empty, the test command will see only: > > test -z > > and treat the missing argument as "yes, this is empty". But > some older shells, reportedly ksh88, complain about the > missing argument. We can be more portable by spelling this > as: > > test -z "$foo" > > so that "test" sees an empty argument, not a missing one. > > This covers all cases detected by: > > git grep 'test -z [^"]' > > (though note that has a few false positives for tests which > need an extra layer of quoting to do '\"'). > > Reported-by: Armin Kunaschik > Signed-off-by: Jeff King > --- > Actually, this misses the case in t4151 which already has a fix queued > on pu. Arguably these should all just be squashed together (and I am > happy, Junio, if you want to do so and leave Armin as the author of the > new commit). 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 -