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

Re: strange arithmetic



In the last episode (Nov 28), Louis-David Mitterrand said:
> > > % i=0;while ! [[ $[++i] < 900 ]];do;echo $i;done
> > > % 1
> > > % 2
> > > [...]
> > > % 90
> > >
> > > Is this normal?
> 
> Thanks to you and zefram, I guess I've been exposed to Perl for a little
> too long (the time I could put off learning shell scripting ;-).
> 
> And to think I thought I had discovered a bug in mighty zsh ..

I'm not sure what Perl has to do with your confusion, unless Perl uses
[[ .. ]] to signify arithmetic evaluation?  I'd check the Perl man
pages, but as they are split into 35 (!!!!!) sections, I won't.  Thank
goodness for "man zshall".

I think [[ ]] is a builtin version of the test command, with more
testing capabilities.

You probably wanted to use the (( )) construct in zsh, to do arithmetic
evaluation of your test.

	-Dan Nelson
	dnelson@xxxxxxxxxxxx



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