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

RE: Re: repeat count?



On Mon, 16 Jan 2023 19:04:07 +0000, Stephane Chazelas <stephane@xxxxxxxxxxxx> wrote:
> 2023-01-16 19:05:21 +0100, Dominik Vogt:
>> Is it possible to get the pass number of a repeat loop from within
>> the loop, or is it necessary to use a hand written counter?
>> 
>>   repeat 10; do
>>     echo "pass number ???"
>>   done
> [...]
>
> You can always do:
>
> n=0; repeat 10 echo pass number $((++n))
>
> Or a la ksh93
>
> for ((n=1;n<=10;n++)) echo pass number $((++n))

Me didn't realize that {--,++} were supported. That appears to be
useful -- thanks.

         --zeurkous.

-- 
Friggin' Machines!




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