From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17364 invoked by alias); 27 Jan 2016 10:02:25 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 37816 Received: (qmail 27117 invoked from network); 27 Jan 2016 10:02:24 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f4-f79026d00000418a-b1-56a8934fae1a Date: Wed, 27 Jan 2016 09:52:12 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Error status of "repeat" (was Re: [PATCH] typeset: set $? on incidental error) Message-id: <20160127095212.686e3362@pwslap01u.europe.root.pri> In-reply-to: <160126201513.ZM2538@torch.brasslantern.com> References: <20160123235300.GC20278@tarsus.local2> <56A445E0.50706@gmx.com> <20160126225008.GA4731@tarsus.local2> <160126201513.ZM2538@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrELMWRmVeSWpSXmKPExsVy+t/xy7r+k1eEGdyazWVxsPkhkwOjx6qD H5gCGKO4bFJSczLLUov07RK4MrYu7mEreMlT0TPtFUsDYzNXFyMnh4SAicS3swdYIGwxiQv3 1rN1MXJxCAksZZT4+7uXGcKZwSTx7udlJgjnHKPEmW8v2CGcs4wSr1cuButnEVCVuLN9EyOI zSZgKDF102wwW0RAXOLs2vNgNcICsRLn171nArF5Bewlrt74wgxicwpYSiw99Y4FYugiRont Wz+ANfML6Etc/fuJCeJAe4mZV84wQjQLSvyYfA9sKLOAlsTmbU2sELa8xOY1b8GGCgmoS9y4 u5t9AqPwLCQts5C0zELSsoCReRWjaGppckFxUnquoV5xYm5xaV66XnJ+7iZGSEh/2cG4+JjV IUYBDkYlHt4b+5eHCbEmlhVX5h5ilOBgVhLhZZmwIkyINyWxsiq1KD++qDQntfgQozQHi5I4 79xd70OEBNITS1KzU1MLUotgskwcnFINjJsOM9UriF4ttRJQsz0btu7/Rc8D/7YyXWk6xM79 5ETmuaruya+nq1p6fq3TY0vrDblqvMT10crjnJ/rFlcqbH+SM99bz+Ak807GmTdONix7JDTx dCnnZG53hpUczeHTZgYlqKd7/LJVZNT4P0Ep9s23na67LNTvGwbPq97rfJj1+kJNHV2fu0os xRmJhlrMRcWJANZyK01lAgAA On Tue, 26 Jan 2016 20:15:13 -0800 Bart Schaefer wrote: > On Jan 26, 10:50pm, Daniel Shahaf wrote: > } > } What would you expect "repeat 0+++ (exit 42)" to set $? to? >... > diff --git a/Src/loop.c b/Src/loop.c > index 4def9b6..61dad09 100644 > --- a/Src/loop.c > +++ b/Src/loop.c > @@ -493,7 +493,7 @@ execrepeat(Estate state, UNUSED(int do_exec)) > tmp = ecgetstr(state, EC_DUPTOK, &htok); > if (htok) > singsub(&tmp); > - count = atoi(tmp); > + count = mathevali(tmp); > pushheap(); > cmdpush(CS_REPEAT); > loops++; As it's documented that this is how it works, and it's hard to see how it can break anything that already works since that will have to be an integer at this point, that looks OK. > -- that doesn't change the exit status! > > torch% repeat 0+++ (exit 42) > zsh: bad math expression: lvalue required > torch% print $? > 0 That message comes from a zerr() in the code. It suggests repeat isn't testing the error status between the code you've just added and executing the loop --- as atoi() won't fail, just give potential nonsense, this wasn't needed before. Probably "if (errflag) return;" before the pushheap() is correct. The error comes from the expansion, not the loop itself which isn't executed, so the status is going to be 1, and clearly repeating the loop 0 times if the +'s are stripped is going to give status 0. The "if (htok) singsub();" is related to some not very obvious syntactic sequence, but I remember I did manage to trigger the equivalent when changing the "case" code last year. pws