From 03695f4b5819d5f20ad0ad241d9255ba8cbd8e91 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Thu, 20 Jul 2023 10:46:14 +0100 Subject: 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. --- Src/jobs.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Src') 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; + } } } -- cgit 1.4.1