-a vs -e

2013-09-05 Thread kneufeld
According to the man page, [ -a ] and [ -e ] should have the same behaviour. -a file True if file exists. ... -e file True if file exists. $ touch stuff.txt $ [ -a stuff.txt ]; echo $? 0 $ [ -e stuff.txt ]; echo $? 0 $ [ ! -e stuff.txt ]; echo $? 1 $ [ ! -a stuff.txt ]; echo $? 0 # wh

Re: -a vs -e

2013-09-05 Thread Greg Wooledge
On Wed, Sep 04, 2013 at 10:06:16PM -0700, kneuf...@gmail.com wrote: > $ [ ! -e stuff.txt ]; echo $? > 1 > $ [ ! -a stuff.txt ]; echo $? > 0 # what? > > Both these version show the exact same behaviour. > > Fedora 18, bash 4.2.45(1)-release > OSX, 3.2.48(1)-release Also occurs in 4.3.0-beta.

Re: -a vs -e

2013-09-05 Thread Eric Blake
On 09/04/2013 11:06 PM, kneuf...@gmail.com wrote: > According to the man page, [ -a ] and [ -e ] should have the same behaviour. Not a bug. -a behaves like -e only when it is unambiguously parsed as a unary operator, because it is bash extension as a unary operator. > > -a file > True if fi

Re: -a vs -e

2013-09-05 Thread Eric Blake
On 09/05/2013 10:33 AM, Greg Wooledge wrote: > On Wed, Sep 04, 2013 at 10:06:16PM -0700, kneuf...@gmail.com wrote: >> $ [ ! -e stuff.txt ]; echo $? >> 1 >> $ [ ! -a stuff.txt ]; echo $? >> 0 # what? >> >> Both these version show the exact same behaviour. >> >> Fedora 18, bash 4.2.45(1)-release

Re: -a vs -e

2013-09-05 Thread Eric Blake
[moving to the coreutils list, as coreutils has a bug here] On 09/05/2013 10:33 AM, Eric Blake wrote: > On 09/04/2013 11:06 PM, kneuf...@gmail.com wrote: >> According to the man page, [ -a ] and [ -e ] should have the same behaviour. > > Not a bug. -a behaves like -e only when it is unambiguousl

Re: -a vs -e

2013-09-05 Thread Chet Ramey
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 9/5/13 12:45 PM, Eric Blake wrote: > The POSIX wording states for 3-argument tests > (http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html): > > ? If $2 is a binary primary, perform the binary test of $1 and $3. > ? If $1 is ?!?, ne

Re: -a vs -e

2013-09-05 Thread Chet Ramey
On 9/5/13 1:06 AM, kneuf...@gmail.com wrote: > According to the man page, [ -a ] and [ -e ] should have the same behaviour. `test' behaves according to the number of arguments supplied. The rules are explained in the manual. The three-argument case is well defined: 3 arguments