From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28509 invoked by alias); 7 Nov 2016 09:39:04 -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: 39854 Received: (qmail 21412 invoked from network); 7 Nov 2016 09:39:04 -0000 X-Qmail-Scanner-Diagnostics: from mailout2.w1.samsung.com 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(210.118.77.12):SA:0(-2.0/5.0):. Processed in 0.506075 secs); 07 Nov 2016 09:39:04 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=RP_MATCHES_RCVD autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at samsung.com does not designate permitted sender hosts) X-AuditID: cbfec7f5-f79ce6d000004c54-e3-58204bad9754 Date: Mon, 07 Nov 2016 09:38:54 +0000 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Bug (?) with "return" from inside "while" Message-id: <20161107093854.687f433a@pwslap01u.europe.root.pri> In-reply-to: <161105151609.ZM19059@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+NgFnrDIsWRmVeSWpSXmKPExsWy7djP87prvRUiDE4tELA42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGWf/nGApaBGoaH63g62B8RJPFyMHh4SAicSClcldjJxAppjE hXvr2boYuTiEBJYyShya0cUM4f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j6llHi9+7jYA38AvoS V/9+YoI40F5i5pUzjBDNghI/Jt8Dq2EW0JLYvK2JFcKWl9i85i3YEUIC6hI37u5mn8AoPAtJ yywkLbOQtCxgZF7FKJJaWpybnltsqFecmFtcmpeul5yfu4kRGEnbjv3cvIPx0sbgQ4wCHIxK PLwCNvIRQqyJZcWVuYcYJTiYlUR4gz0VIoR4UxIrq1KL8uOLSnNSiw8xmgJDZiKzlGhyPjDK 80riDU0MzS0NjYwtLMyNjJTEeUs+XAkXEkhPLEnNTk0tSC2C6WPi4JRqYNT9aSPUGfbRvt1Z 5p7fLNOsj/cjmu33MHEH765umlj2ecuBz409LaZ/1nYGN8x6LyEvEJWzZX+uxw9Dxa/XDSU/ S7MvvbWC8/W+Rx8/X7e82mC9jDv0hd07ibT6P4+8GE89PhtvPPvJy7UBMj9EH9TkikVoPlps 08FU8tX7w95t24uipF187iuxFGckGmoxFxUnAgDZdYygugIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20161107093852eucas1p2fa9ab31ce988ebeb080b0d1f55474b47 X-Msg-Generator: CA X-Sender-IP: 182.198.249.179 X-Local-Sender: =?UTF-8?B?UGV0ZXIgU3RlcGhlbnNvbhtTQ1NDLURhdGEgUGxhbmUb?= =?UTF-8?B?7IK87ISx7KCE7J6QG1ByaW5jaXBhbCBFbmdpbmVlciwgU29mdHdhcmU=?= X-Global-Sender: =?UTF-8?B?UGV0ZXIgU3RlcGhlbnNvbhtTQ1NDLURhdGEgUGxhbmUbU2Ft?= =?UTF-8?B?c3VuZyBFbGVjdHJvbmljcxtQcmluY2lwYWwgRW5naW5lZXIsIFNvZnR3YXJl?= X-Sender-Code: =?UTF-8?B?QzEwG0VIURtDMTBDRDA1Q0QwNTAwNTg=?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20161105222418epcas3p4e3bc4de7446b9d713f6899f5203abf90 X-RootMTR: 20161105222418epcas3p4e3bc4de7446b9d713f6899f5203abf90 References: <161105132509.ZM17198@torch.brasslantern.com> <161105140043.ZM17511@torch.brasslantern.com> <161105151609.ZM19059@torch.brasslantern.com> On Sat, 5 Nov 2016 15:16:09 -0700 Bart Schaefer wrote: > As best I can tell, the exit value of a "while" loop is supposed to > be the exit value of the last executed statement in the loop-body, > but the value of $? on entry to the loop body is supposed to be the > value of the last executed statement in the condition. Yes, that just got fixed for certain constructs. > The question is what the exit status should be if the conditional > includes an explicit "return N". dash and zsh up to this point > return the exit status of the loop body, or zero if the loop body > has never executed. Bash returns N, which seems more correct. You'd think so. > A related question is what happens if the loop is interrupted with > ^C. The most recent changes to execwhile() are all about handling > that (plus making the interrupt possible if the condition or body > or both are empty). Is an interrupted condition the same as one > that returned false (or true in the case of until)? This somewhat > obscures what is intended in the case where there is no interrupt. If it's interrupted, any stack of callers should be interrupted, too. The status should only be significant when you get back to the top level, or exit the shell, and this should happen if errflag is et. Then it should fix up a suitable status at that opint. So the key thing internally is making sure it does get interrupted. > There's also the question of what $? should be upon entry to the > condition. On the first loop it's unchanged from the previous > command, but on successive loops it's the value from the loop body. > On the other hand the value of $? on entry to the loop body is the > value from the condition (always 0 for while, nonzero for until). > (Patch below doesn't address this at all.) That's not obviously stupid. Those are the last commands to have been executed. Recently found problems were due to clearing it when it shouldn't be, rather than leaving it do the last value. pws