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

Re: [[ and [



On Tue, Mar 06, 2012, Mikael Magnusson wrote about "Re: [[ and [":
> Incidentally, this is probably the most confusing error message ever,
> % [ $foo == "" ]
> zsh: = not found

I see something slightly different. On zsh 4.3.15, with unset $foo, I
get:

	$ [ $foo == "" ]
	zsh: parse error: condition expected: ==

Which indeed is not very clear, but arguably not "the most confusing
error message ever" ;-)
To compare, GNU test shows this:

	$ /usr/bin/[ $foo == "" ]
	/usr/bin/[: missing argument after `'

Bash shows:

	$ [ $foo == "" ]
	bash: [: ==: unary operator expected

Ksh shows
	$ [ $foo == "" ]
	ksh: [: argument expected

I'm not sure which is clearest, probably ksh's.
If it were up to me, I'd say something like:

	$ [ $foo == "" ]
	zsh: parse error: ==: missing first argument.

-- 
Nadav Har'El                        |                  Wednesday, Mar 7 2012, 
nyh@xxxxxxxxxxxxxxxxxxx             |-----------------------------------------
Phone +972-523-790466, ICQ 13349191 |A language is a dialect with an army.
http://nadav.harel.org.il           |



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