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

Re: About 'test' compatibility



On Tue, 26 Feb 2002, DervishD wrote:

> >No, it's the -d in $DEFAULT that's confusing it.  When $DEFAULT is
> >-d, zsh is treating the above as "if there is a directory named `='
> >..."
>
>     Just curiosity: why BASH doesn't fail here too? The 'test'
> builtin of the Bourne shell has the '-d' too.

It appears that bash gives the infix '=' higher precedence than the prefix
'-d' or the infix '-a':

bash2-2.03$ mkdir '='
bash2-2.03$ if [ "-d" = ]; then echo There is a directory; fi
There is a directory
bash2-2.03$ if [ -d = -x ]; then echo There is a directory; fi
bash2-2.03$ if [ -d = -a x ]; then echo There is a directory; fi
[: too many arguments
bash2-2.03$ if [ -d . -a x ]; then echo There is a directory; fi
There is a directory

I haven't checked whether e.g. POSIX says anything about this.



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