Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "set -e" handling is broken with zsh 5.3.1 and 5.4.1
- X-seq: zsh-workers 41608
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: "set -e" handling is broken with zsh 5.3.1 and 5.4.1
- Date: Sun, 27 Aug 2017 19:56:48 +0100
- 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==
- In-reply-to: <20170827005040.GA12622@zira.vinc17.org>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <20170827005040.GA12622@zira.vinc17.org>
On Sun, 27 Aug 2017 02:50:40 +0200
Vincent Lefevre <vincent@xxxxxxxxxx> 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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author