about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
authorPeter Stephenson <p.stephenson@samsung.com>2023-07-20 10:46:14 +0100
committerPeter Stephenson <p.stephenson@samsung.com>2023-07-20 10:46:14 +0100
commit03695f4b5819d5f20ad0ad241d9255ba8cbd8e91 (patch)
tree71bd1766cc08c1cec0ab1333440e308d0225d7fe /Src
parent5ec4695033b9a3a57492b60439d9e3a922d9bcd1 (diff)
downloadzsh-03695f4b5819d5f20ad0ad241d9255ba8cbd8e91.tar.gz
zsh-03695f4b5819d5f20ad0ad241d9255ba8cbd8e91.tar.xz
zsh-03695f4b5819d5f20ad0ad241d9255ba8cbd8e91.zip
51977: PIPEFAIL interaction with ERREXIT / ERRRETURN
Ensure the list-level error handling code is executed if we detect pipe failure for a foreground job.

Add tests.
Diffstat (limited to 'Src')
-rw-r--r--Src/jobs.c16
1 files changed, 11 insertions, 5 deletions
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;
+	}
     }
 }