Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: strange arithmetic
- X-seq: zsh-users 1160
- From: Andrew Main <zefram@xxxxxxxxx>
- To: mito@xxxxxxxxxxx
- Subject: Re: strange arithmetic
- Date: Fri, 28 Nov 1997 19:37:05 +0000 (GMT)
- Cc: zsh-users@xxxxxxxxxxxxxxx
- In-reply-to: <19971128140924.07137@retriever> from "Louis-David Mitterrand" at Nov 28, 97 02:09:24 pm
Louis-David Mitterrand wrote:
>% i=0;while [[ $[++i] < 900 ]];do;echo $i;done
"<" does a string comparison. For a numeric comparison, you want "-lt".
>% i=0;while ! [[ $[++i] = 900 ]];do;echo $i;done
"=" (or the preferred "==") also does string comparison. You should
really use "-eq" here.
I've just noticed that this is exactly the opposite convention from Perl.
I can even see why the difference was historically inevitable.
-zefram
Messages sorted by:
Reverse Date,
Date,
Thread,
Author