Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Failed pipeline doesn't err_exit/return if complex command last
- X-seq: zsh-workers 51962
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: Johan Grande <nahoj@xxxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: Failed pipeline doesn't err_exit/return if complex command last
- Date: Tue, 18 Jul 2023 14:57:20 +0100 (BST)
- Archived-at: <https://zsh.org/workers/51962>
- Importance: Normal
- In-reply-to: <CAH+w=7bFd6Bnd4X+giWymmtrmCXCHkrBGUmDj3dYmgApJqYniw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <0c1f1b1e-7d2b-ec6b-3044-dc25b6d5a4d5@crans.org> <1263859119.226140.1688636640060@mail.virginmedia.com> <CAH+w=7YThrJn4BBhEt4J6aSfpH0se_0jCwstOeCO5aF-9T7gpw@mail.gmail.com> <CAH+w=7bFd6Bnd4X+giWymmtrmCXCHkrBGUmDj3dYmgApJqYniw@mail.gmail.com>
> fn () {
> emulate -L zsh
> setopt errreturn pipefail
> false | {
> true
> }
> print "Shouldn't get here, status $?"
> }
A bit more prodding reveals it's not actually timing that
has this effect --- the problem is this_noerrexit being
set to indicate something like "we're doing that complicated
internal shell stuff and we've discovered the status is OK".
This time it isn['t.
Not sure if I need the second case or not, certainly
the first case is the one we're hitting here (the
STAT_CURSH is the giveaway). My guess is that it's
simply irrelevant because if there's no STAT_CURSH
we aren't going to hit those cases where this_noerrexit
becomes non-zero.
Obviously, there could be even more complicated cases that
still cause problems, but I think we'll just have to discover
those. I'll write some tests that might help.
Note I fixed some indentation.
pws
diff --git a/Src/jobs.c b/Src/jobs.c
index dd7bba405..a3b9f667a 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -427,11 +427,17 @@ storepipestats(Job jn, int inforeground, int fixlastval)
}
if (fixlastval) {
- if (jn->stat & STAT_CURSH) {
- if (!lastval && isset(PIPEFAIL))
- lastval = pipefail;
- } else if (isset(PIPEFAIL))
- lastval = pipefail;
+ if (jn->stat & STAT_CURSH) {
+ if (!lastval && isset(PIPEFAIL)) {
+ if (inforeground)
+ this_noerrexit = 0;
+ lastval = pipefail;
+ }
+ } else if (isset(PIPEFAIL)) {
+ if (inforeground)
+ this_noerrexit = 0;
+ lastval = pipefail;
+ }
}
}
Messages sorted by:
Reverse Date,
Date,
Thread,
Author