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 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 # what? But _this_ is an instance where -a is parsed as a binary operator (ie. it was parsed as "\( ! \) -a \( stuff.txt \)", not "! \( -a stuff.txt \)". -a as a binary operator is required by POSIX for XSI, therefore it takes priority over -a as a unary operator as a bash extension. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature