Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Failed pipeline doesn't err_exit/return if complex command last
On Thu, Jul 6, 2023 at 2:44 AM Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
>
\> fn() {
> emulate -L zsh
> setopt errreturn pipefail
> false | { true }
> print "Shouldn't get here, status $?"
> }
>
> The final part of the pipeline is run in the current shell, so the
> job control is a bit fiddly. It looks like the relevant code,
> including the function storepipestats(), is run too late in this
> case.
It's not that it's run too late, it's that it's run too SOON:
pipestatus has already been updated and lastval set, but then we get
here:
4186 if (!errflag) {
4187 int ret = execbuiltin(args, assigns, (Builtin) hn);
4188 /*
4189 * In case of interruption assume builtin status
4190 * is less useful than what interrupt set.
4191 */
4192 if (!(errflag & ERRFLAG_INT))
4193 lastval = ret;
4194 }
and clobber lastval with the result of execbuiltin(). Or that's how
it currently appears from pass through gdb. Per "fiddly" it's a bit
hard to be sure.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author