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


View this message in rfc822 format

From: Reuti <reuti <at> staff.uni-marburg.de>
To: Eric Blake <eblake <at> redhat.com>
Cc: 24894-done <at> debbugs.gnu.org, BAECKEROOT Alain <alain.baeckeroot <at> carsat-sudest.fr>
Subject: bug#24894: coreutils 8.4 : `test -s` without argument does not return an error
Date: Mon, 7 Nov 2016 17:56:08 +0100
[Message part 1 (text/plain, inline)]
> Am 07.11.2016 um 17:46 schrieb Eric Blake <eblake <at> redhat.com>:
> 
> tag 24894 notabug
> thanks
> 
> On 11/07/2016 06:58 AM, BAECKEROOT Alain wrote:
>> Dear gnu-coreutils team
>> 
>> We had a funny problem caused by `test` which does return "0" when an option is given without any EXPRESSION
>> 
>> The man page says (near line 15 or so) :
>>      An  omitted  EXPRESSION defaults to false.
> 
> 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?

But I thought in a similar way: it may be incomplete, but not omitted.

Nevertheless: the bash builtin behaves the same.

@Alain: I have no AIX, but l get the impression that test is also a ksh-builtin. Are you getting the results for both implementations?

-- Reuti


> The full POSIX rules are here:
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
> 
>> I expected an error (at least return code not zero) , or it would be nice to be warned in the man page.
> 
> You are correct that the man page could probably do a bit better at
> explaining that test's behavior is STRONGLY influenced by the number of
> parameters present (and this is per POSIX rules, so it is not just
> coreutils' test implementation, but ALL conforming implementations that
> will behave the same way).
> 
>> -------------
>> reference : On *AIX* 6.1 , with IBM's test , there is an error
>> 
>> wasoi <at> cms054:/i/w/l/w00/was> echo $SHELL
>> /bin/ksh
>> wasoi <at> cms054:/i/w/l/w00/was> uname
>> AIX
>> wasoi <at> cms054:/i/w/l/w00/was> test -s
>> ksh: test: argument expected
> 
> That is a bug in AIX's ksh, which is not POSIX compliant.
> 
>> wasoi <at> cms054:/i/w/l/w00/was> echo $?
>> 1
>> 
>> This was the expected behavior :-)
> 
> Sorry, but that behavior is contrary to POSIX.
> 
>> Ce message électronique, les éventuels fichiers joints et les informations qu'il contient,
> 
> Legalese like this is unenforceable on public mailing lists; you may
> wish to use a personal email account rather than spamming us with your
> employer's garbage disclaimer.
> 
> --
> 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.