GNU bug report logs - #24894
coreutils 8.4 : `test -s` without argument does not return an error

Previous Next

Package: coreutils;

Reported by: BAECKEROOT Alain <alain.baeckeroot <at> carsat-sudest.fr>

Date: Mon, 7 Nov 2016 16:34:01 UTC

Severity: normal

Tags: notabug

Done: Eric Blake <eblake <at> redhat.com>

Bug is archived. No further changes may be made.

Full log


Message #21 received at 24894-done <at> debbugs.gnu.org (full text, mbox):

From: Eric Blake <eblake <at> redhat.com>
To: Reuti <reuti <at> staff.uni-marburg.de>
Cc: 24894-done <at> debbugs.gnu.org,
 BAECKEROOT Alain <alain.baeckeroot <at> carsat-sudest.fr>
Subject: Re: bug#24894: coreutils 8.4 : `test -s` without argument does not
 return an error
Date: Mon, 7 Nov 2016 11:00:29 -0600
[Message part 1 (text/plain, inline)]
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 (application/pgp-signature, attachment)]

This bug report was last modified 8 years and 200 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.