Subject: Re: bug#24894: coreutils 8.4 : `test -s` without argument does not return an error

From: Eric Blake <[email-masked]>
Date: Mon, 7 Nov 2016 11:00:29 -0600

On 11/07/2016 10:56 AM, Reuti wrote:
>> You are correct that it states that, but it means that 'test' (with no
>> expression at all) is what results in a false return (that is, an
>> omitted expression is equivalent to zero arguments).  'test -s' is NOT a
>> case of an omitted expression; your expression was '-s'.  Since you
>> provided exactly one argument, you are testing whether '-s' is the empty
>> string (it is not, hence the true result).
> 
> Doesn't -s refer to a FILE existence, it's not -z?

When there are TWO arguments, '-s "$file"' tests for whether file is
empty, and '-z "$string"' tests for whether $string is empty.  But here
we are talking about ONE argument, '-s', which is non-empty.  (Yes, the
one-argument case is identical to using the two-argument -z "$string" case.)

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org