From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10691 invoked by alias); 9 Jul 2015 13:38:33 -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: 35751 Received: (qmail 996 invoked from network); 9 Jul 2015 13:38:31 -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=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.0 X-AuditID: cbfec7f4-f79c56d0000012ee-9f-559e7952857c Date: Thu, 09 Jul 2015 14:38:23 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: err_exit/err_return regression Message-id: <20150709143823.184fb4e1@pwslap01u.europe.root.pri> In-reply-to: References: 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+NgFjrCLMWRmVeSWpSXmKPExsVy+t/xa7pBlfNCDa7P5LM42PyQyYHRY9XB D0wBjFFcNimpOZllqUX6dglcGVOu3WAvuMRXMeVbP1sD4xmuLkZODgkBE4nZr3rYIWwxiQv3 1rN1MXJxCAksZZS43dHDDOHMYJLYfX8dI4SzlVHi8eSbYC0sAqoSrU9fM4PYbAKGElM3zWYE sUUExCXOrj3PAmILC2hLtC1eC1bDK2AvMaPlIyuIzSkQLLF4/0GwOUICARKP1pwAs/kF9CWu /v3EBHGSvcTMK2cYIXoFJX5Mvgc2k1lAS2LztiZWCFteYvOat8wQc9QlbtzdzT6BUWgWkpZZ SFpmIWlZwMi8ilE0tTS5oDgpPddQrzgxt7g0L10vOT93EyMkbL/sYFx8zOoQowAHoxIPb+PO uaFCrIllxZW5hxglOJiVRHj1POeFCvGmJFZWpRblxxeV5qQWH2KU5mBREuedu+t9iJBAemJJ anZqakFqEUyWiYNTqoHR/uDcNy7GIn/OfNzhVXD4xP5Miet66+WSLG/tOyhwYvNVDe776VPV T6tH7uAMmuZ1XHnb2k0e83/m5hw4OVfZrWbxzIyErR5L2UIvXeU84qqy3m7PYam9Qlv/s3Tv j/ntanxF5Z+tt5jcsa9FtecfbeAwefQ0JOBhkdPDgrDP92auS1jHO9HVRYmlOCPRUIu5qDgR ANx62XhXAgAA On Thu, 9 Jul 2015 13:33:09 +0200 jsks wrote: > Since patch 34065, with either err_exit or err_return set, zsh does > not exit/return given a nonzero exist status of a command following > 'else'. Hmm, this code is quite hairy and is crying out to be a bit more structured (it's not lonely in that respect). But the test suite says the following is good enough for now. diff --git a/Src/exec.c b/Src/exec.c index 960601f..4eee82b 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1351,7 +1351,13 @@ execlist(Estate state, int dont_change_job, int exiting) state->pc--; sublist_done: - noerrexit = oldnoerrexit; + /* + * See hairy code near the end of execif() for the + * following. "noerrexit == 2" only applies until + * we hit execcmd on the way down. We're now + * on the way back up, so don't restore it. + */ + noerrexit = (oldnoerrexit == 2) ? 0 : oldnoerrexit; if (sigtrapped[SIGDEBUG] && !isset(DEBUGBEFORECMD) && !donedebug) { /* diff --git a/Test/C03traps.ztst b/Test/C03traps.ztst index 757f75c..4e23388 100644 --- a/Test/C03traps.ztst +++ b/Test/C03traps.ztst @@ -399,6 +399,46 @@ ) 1:ERREXIT in loop with simple commands + fn() { + emulate -L zsh + setopt errreturn + if false; then + false + print No. + else + print Oh, yes + fi + } + fn +0:ERRRETURN not triggered in if condition +>Oh, yes + + fn() { + emulate -L zsh + setopt errreturn + if true; then + false + print No. + else + print No, no. + fi + } + fn +1:ERRRETURN in "if" + + fn() { + emulate -L zsh + setopt errreturn + if false; then + print No. + else + false + print No, no. + fi + } + fn +1:ERRRETURN in "else" branch (regression test) + %clean rm -f TRAPEXIT