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

Re: Is this really correct ?



> gene@xxxxxxxx (gene@xxxxxxxx) wrote:
> > 
> > 
> >    Hpux 9.05.
> > 
> > % echo $ZSH_VERSION
> > 2.6-beta20
> > % a="-s"; if [ "$a" = "-s" ] ;  then echo "yeh" ; fi 
> > % 
> > 
> > (if fails)
> 
> If $a is -s, then the test builtin probably tests for whether file '='
> exists and has a size greater than zero :-). This works for me:
> $ echo hi > =
> $ a="-s"; if [ "$a" = "-s" ] ;  then echo "yeh" ; fi
> yeh
> 
> Thus, it may be an sh incompatibility, but not a bug. Unless the shell
> is supposed to count the arguments first, and then use draw the
> conclusions according to the argument values (in which case the middle
> argument would recognized as two-operand =).

POSIX 1003.2 says that if test has three arguments and $2 is a binary
operator then perform the binary test of $1 and $3.  If $1 is `!', negate
the two-argument test of $2 and $3.  Otherwise, produce unspecified
results.

Zsh will be modified according to this (which is more logical than the
present behaviour).

Zoltan




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