From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17374 invoked by alias); 27 Aug 2017 19:03:59 -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: 41608 Received: (qmail 27396 invoked by uid 1010); 27 Aug 2017 19:03:59 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-10.server.virginmedia.net 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(80.0.253.74):SA:0(-4.7/5.0):. Processed in 2.605813 secs); 27 Aug 2017 19:03:59 -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=-4.7 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Originating-IP: [86.21.219.59] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.1 cv=SeoKDalu c=1 sm=1 tr=0 a=utowdAHh8RITBM/6U1BPxA==:117 a=utowdAHh8RITBM/6U1BPxA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=kj9zAlcOel0A:10 a=x7bEGLp0ZPQA:10 a=YR4_K0clAAAA:8 a=6-_JsmhfLGBbM84mKSsA:9 a=CjuIK1q_8ugA:10 a=waMAY2KAzxQUlx2gRwsv:22 Date: Sun, 27 Aug 2017 19:56:48 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: "set -e" handling is broken with zsh 5.3.1 and 5.4.1 Message-ID: <20170827195648.6f078249@ntlworld.com> In-Reply-To: <20170827005040.GA12622@zira.vinc17.org> References: <20170827005040.GA12622@zira.vinc17.org> X-Mailer: Claws Mail 3.11.1 (GTK+ 2.24.28; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ntlworld.com; s=meg.feb2017; t=1503860208; bh=VanJvJubHebSLUbNYHE14/0mnDTpgcFbyaYou0CfJ04=; h=Date:From:To:Subject:In-Reply-To:References; b=pfpvjW9OlD3TbeqUDUW/lXB7LgeWYAY+kOXgJEdvmLxOvSds8tMEJCHK+JOt8TIK3 lW92b2p1vJsskGHSy9KBUONkSGVsDpr7N5ZLwN1EXn4h/Cy0DMSGWxk8lBoxzy7GbV Q9GOemava9/Cz/wd1LX+a2cTfdv3/FjXUlQcHlXIIQY60iHquojkmBSE4P6bUIUBfH h3JXaVL5Ib5Wl4o03pRU95Y0HjZjVUI582jvcH55aW1q6jDdgUT+QMA1pjovllcFJu fiH9B30UqnrvMmcdkLHYLWe6tlmHfty9jj4W0nfUzpZNC5m5BxBlJXXTlMUkjID67u jrb+cJ4s//l/Q== On Sun, 27 Aug 2017 02:50:40 +0200 Vincent Lefevre wrote: > Consider: > > ---------------------------------------- > #!/usr/bin/env zsh > > set -e > > f() > { > [[ -z 1 ]] && false > } > > if false; then > : > else > f > echo Fail 1 > echo Fail 2 > f > echo Fail 3 > fi > ---------------------------------------- > > With > zsh 5.3.1-4+b1 under Debian/stretch > zsh 5.4.1-1 under Debian/unstable > > I get: > > % ./cond2-e; echo $? > Fail 1 > Fail 2 > 1 > > I suppose that cond2-e should die just after f is called, before > outputting anything. Yes, I would say so. This appears to have been deliberate, in that after "if" we usually restore noerrexit beahaviour on the first thing we execute, but if it's a function we don't. However, I can't for the life of me work out why I made that exeception --- certainly nothing goes wrong in the tests if I apply the following, and I would expect to be testing whatever it was made me think we needed the qualification. It might have been to do with empty functions, but making f empty, so it runs but doesn't change the status, doesn't seem to do anything unexpected (we shouldn't and don't exit). I think I'll apply the effect of this after the release of 5.4.2, with a test based on the code above plus some empty functions just in case, and see what happens. In the mean time somebody may find a more fiendish variant involving functions that causes a further problem. pws diff --git a/Src/exec.c b/Src/exec.c index cd99733..82277a3 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -3025,7 +3025,7 @@ execcmd_exec(Estate state, Execcmd_params eparams, preargs = NULL; /* if we get this far, it is OK to pay attention to lastval again */ - if ((noerrexit & NOERREXIT_UNTIL_EXEC) && !is_shfunc) + if ((noerrexit & NOERREXIT_UNTIL_EXEC)/* && !is_shfunc*/) noerrexit = 0; /* Do prefork substitutions.