[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#20130: GNU test behaviour
From: |
Pádraig Brady |
Subject: |
bug#20130: GNU test behaviour |
Date: |
Wed, 18 Mar 2015 10:04:37 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
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.