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

conditional expressions (incompatible with ksh)



Hello,

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.

According to my "Unix in a Nutshell" book, -a is used for both operators,
and the shell needs to determine the correct use from context.

I realize that I could use [[ ]] instead of [ ] to work around this problem,
but the script needs to remain compatible with other shells, so this isn't
really a good option.

Any idea what the correct behavior should be?

mdr
-- 
Matthew D. Rench



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