Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Problems with for loops
- X-seq: zsh-users 2905
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: "Allen Belk" <allen.belk@xxxxxxx>, <zsh-users@xxxxxxxxxxxxxx>
- Subject: Re: Problems with for loops
- Date: Wed, 2 Feb 2000 11:27:23 -0800
- In-reply-to: <000501bf6dac$568a7420$3e525f83@xxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <000501bf6dac$568a7420$3e525f83@xxxxxxxxxxx>
On Feb 2, 12:35pm, Allen Belk wrote:
> Subject: Problems with for loops
>
> #!/bin/zsh
> ((i = 0))
> for (( i -eq 0; i -le 10; i++ )) do echo "$i\n" done
>
> ./array_test.zsh: parse error near `(( i -eq 0' [3]
Although the other answers so far have been correct, they've missed one
crucial detail: You're using zsh 3.0.something, and the "for ((...))"
syntax is a new feature introduced by zsh 3.1.3 (I think it was). If
you were using 3.1.6, for example, the error message would be "bad
math expression" rather than "parse error."
The 3.1 series is a beta release, so think carefully before upgrading.
The equivalent of the above "for" loop in syntax that 3.0 does support:
((i = 0))
while ((i <= 10)) do echo "$i"; ((i++)); done
Messages sorted by:
Reverse Date,
Date,
Thread,
Author