Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: conditional expressions (incompatible with ksh)



lists@xxxxxxxxxxxx wrote:
 
> So I have a ksh script which tests to see if a file exists like so:
> 
>      if [ -a file ]; then
 
> This works correctly in both ksh and bash. However, in zsh (both the
> normal mode, and the ksh compatible mode), the -a operator is only
> interpreted as boolean AND, never as "file exists" in the appropriate
> context.

perhaps someone can give a more detailed answer, but the '-a' operator
isn't mentioned in my bash scripting book, and i've never seen this
operator used (although i'll admit it works in bash and not in zsh).
how about using instead....

-e file exists
-f file exists and is a regular file (ie not a directory)
-s file exists and is not empty

i'd guess -f or -e is probably what you want and should work in bash,
ksh and zsh.

w

-- 
GPG Public Key:
http://infinitejazz.net/will/pgp/



Messages sorted by: Reverse Date, Date, Thread, Author