Re: t3404 static check of bad SHA-1 failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Jeff King <peff@xxxxxxxx> writes:

> 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.

Are you doing an audit?  Otherwise I'm interested in taking a brief
look.

>> 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).

Perhaps.

A small consolation for ksh fans around is that ksh93 seems to get
this case right ;-)
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]