[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#24894: coreutils 8.4 : `test -s` without argument does not return an
From: |
Eric Blake |
Subject: |
bug#24894: coreutils 8.4 : `test -s` without argument does not return an error |
Date: |
Mon, 7 Nov 2016 11:00:29 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 |
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
signature.asc
Description: OpenPGP digital signature