Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: dangerous behavior of while in zsh 5.6 ?
- X-seq: zsh-users 23697
- From: Marc Chantreux <eiro@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Subject: Re: dangerous behavior of while in zsh 5.6 ?
- Date: Wed, 3 Oct 2018 18:25:52 +0200
- Cc: Zsh Users <zsh-users@xxxxxxx>
- Dkim-filter: OpenDKIM Filter v2.10.3 aurora-borealis.phear.org 69E4110699
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/simple; d=phear.org; s=20180217; t=1538583954; bh=Jat2WFJ5LvBXocLUDFoin80WwLnH/5cBKnHX+4x0IeY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VEAsImriz8YTC5tHPTYAy6Q/SyQABJxszgEhRaFwvORNhbioZFl6wt2gqPv/FmSDn Agrcp0bqUGBmiWiY4tsVp64OUn3daeLot7R2NHcTl0vA1SMV3ykv25doUIIBiTk6BO +N0DCGMXRc9+uU+m9Z78DVGEsLnNIGhejEtWRMVun6BRTEk8WWDRddRCzJJTN2X77Z p9GX6qHPri7RwzR0FPuuCvubBDJQLhdzg0pQXgGZDxxkD2KEmJgBOf2NOsTGyvG+x/ KpEWIvpucU/4Zk3ypvbhbjbHUJAz/ES3uoYtMVrDbC8O7fAar8N68yblCeNacrM5qA 7uSXqce+nP80Q==
- In-reply-to: <CAH+w=7ZuFKDMBvL7XdSqYXcXy5hrc_zQPK0KsLrTZ1Szrfu6Ow@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <20181003143800.GA9162@prometheus.u-strasbg.fr> <CAH+w=7ZuFKDMBvL7XdSqYXcXy5hrc_zQPK0KsLrTZ1Szrfu6Ow@mail.gmail.com>
hello Bart,
> > while (( i-- ))
> > print $i
> This is just a syntax error for me (or prints the PS2 prompt if
> interactive), so I'm not sure how you're getting it to do anything.
i have the same behavior when interactive but no syntax error otherwise.
instead:
{ repeat 2 print $[i++]
while (( i-- )) print $i
} |sed 10 | xargs
> 0 1 1 0
{ repeat 2
print $[i++]
while (( i-- ))
print $i
} |sed 10q | xargs
> 0 1 1 0 -1 -2 -3 -4 -5 -6
but thanks to your enlightening explainations, i understand what's going
on and now have a short, gorgeous way to write a forever loop.
nat () {
local -i x=${1-0}
while print $[x++]
}
thank you very much, Bart.
regards.
marc
Messages sorted by:
Reverse Date,
Date,
Thread,
Author