GNU bug report logs - #20130
GNU test behaviour

Previous Next

Package: coreutils;

Reported by: Robson Júnior <robsonjrce <at> gmail.com>

Date: Tue, 17 Mar 2015 21:26:01 UTC

Severity: normal

Tags: notabug

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

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 20130 in the body.
You can then email your comments to 20130 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#20130; Package coreutils. (Tue, 17 Mar 2015 21:26:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Robson Júnior <robsonjrce <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Tue, 17 Mar 2015 21:26:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Robson Júnior <robsonjrce <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: GNU test behaviour
Date: Tue, 17 Mar 2015 18:23:01 -0300
[Message part 1 (text/plain, inline)]
Hi,

I'm currently very curious about something i couldn't read from man pages.

`test -e <FILENAME>` checks if a file exists... that's why i couldn't agree
with the return of the execution `test -e` with no filename being passed
to. It returns 0, although it should be 1.

Is it right?

-- 

Robson Júnior
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#20130; Package coreutils. (Tue, 17 Mar 2015 22:28:02 GMT) Full text and rfc822 format available.

Message #8 received at 20130 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Robson Júnior <robsonjrce <at> gmail.com>, 
 20130 <at> debbugs.gnu.org
Subject: Re: bug#20130: GNU test behaviour
Date: Tue, 17 Mar 2015 15:27:02 -0700
On 03/17/2015 02:23 PM, Robson Júnior wrote:
> `test -e` with no filename being passed to. It returns 0, although it 
> should be 1. 

No, 'test -e' should exit with status 0, because '-e' is a nonempty 
string.  In general, 'test X' exits with status 0 if and only if X is 
nonempty.  POSIX requires this behavior; see:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html

and search for "1 argument".




Added tag(s) notabug. Request was from Eric Blake <eblake <at> redhat.com> to control <at> debbugs.gnu.org. (Tue, 17 Mar 2015 23:00:04 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 20130 <at> debbugs.gnu.org and Robson Júnior <robsonjrce <at> gmail.com> Request was from Eric Blake <eblake <at> redhat.com> to control <at> debbugs.gnu.org. (Tue, 17 Mar 2015 23:00:04 GMT) Full text and rfc822 format available.

Information forwarded to bug-coreutils <at> gnu.org:
bug#20130; Package coreutils. (Wed, 18 Mar 2015 10:05:01 GMT) Full text and rfc822 format available.

Message #15 received at 20130 <at> debbugs.gnu.org (full text, mbox):

From: Pádraig Brady <P <at> draigBrady.com>
To: Robson Júnior <robsonjrce <at> gmail.com>, 
 20130 <at> debbugs.gnu.org
Subject: Re: bug#20130: GNU test behaviour
Date: Wed, 18 Mar 2015 10:04:37 +0000
tag 20130 notabug
close 20130
stop

On 17/03/15 22:27, Paul Eggert wrote:
> On 03/17/2015 02:23 PM, Robson Júnior wrote:
>> `test -e` with no filename being passed to. It returns 0, although it 
>> should be 1. 
> 
> No, 'test -e' should exit with status 0, because '-e' is a nonempty 
> string.  In general, 'test X' exits with status 0 if and only if X is 
> nonempty.  POSIX requires this behavior; see:
> 
> http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html
> 
> and search for "1 argument".

If the filename is in a shell variable,
this is another reason for quoting.
I.E. this will work reliably:

  file=blah
  test -e "$file" || echo missing

thanks,
Pádraig.





bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 15 Apr 2015 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 69 days ago.

Previous Next


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