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

Re: [[ and [



On 6 March 2012 12:44, Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
> On Tue, 6 Mar 2012 11:35:32 +0000
> Peter Stephenson <Peter.Stephenson@xxxxxxx> wrote:
>> However,
>>
>>   [[ $foo -eq "" ]]
>>
>> does exactly what it looks like it does
>
> Sigh.  Sort of.  [ ... -eq ...] and [[ ... -eq ... ]] are numeric tests,
> so if foo is a string of zeros it's not doing what it looks like.  I
> should have said
>
>  [ $foo = "" ]]
>
> and
>
>  [[ $foo = "" ]]
>
> or
>
>  [[ $foo == "" ]]
>
> I don't know why it's that way round, it seems a bit illogical (which is
> why Perl is the other way), but it always has been that way.

Incidentally, this is probably the most confusing error message ever,
% [ $foo == "" ]
zsh: = not found

-- 
Mikael Magnusson



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