From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-users-return-23697-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 9f333e83 for ; Wed, 3 Oct 2018 16:26:24 +0000 (UTC) Received: (qmail 3561 invoked by alias); 3 Oct 2018 16:26:09 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: List-Unsubscribe: X-Seq: 23697 Received: (qmail 4519 invoked by uid 1010); 3 Oct 2018 16:26:09 -0000 X-Qmail-Scanner-Diagnostics: from aurora-borealis.phear.org by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(94.242.205.164):SA:0(-1.9/5.0):. Processed in 2.679012 secs); 03 Oct 2018 16:26:09 -0000 X-Envelope-From: eiro@phear.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Virus-Scanned: amavisd-new at phear.org 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== Date: Wed, 3 Oct 2018 18:25:52 +0200 From: Marc Chantreux To: Bart Schaefer Cc: Zsh Users Subject: Re: dangerous behavior of while in zsh 5.6 ? Message-ID: <20181003162552.GA14697@prometheus.u-strasbg.fr> References: <20181003143800.GA9162@prometheus.u-strasbg.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) 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