From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 11281 invoked from network); 20 Jul 2023 08:48:18 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 20 Jul 2023 08:48:18 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1689842898; b=IJ4eJoh9gtcBYcDuwpbKUpqXF6VlO/WlbMeWyYQ/gbIxFpB5XNG4a8/9eN4y/3vRORRwBIaz1O Ey2kMFmFmWSnYX7jVALmBm88mahnq7vPhA14VXWDkxrr+ESRlzn6royRzR0X3elaAt6U/U/8K4 vwbaaI951Q0Z/Z9eJKq+iILl4Iq6jO3W+8x16RyeW7JJWuBpJcOij36hnUbtH9J/7NfurJPaEt f/E3ukwpk3HogVdFpg/qJMNmRX7vyTGVmBck6gu79b3QzaCCVwc5aDeUbsUsBqWhbFSS9xDdiZ k9q1sJMxp7cugAi3dNLAFuueq6xHYfwq47duLjnCpP1YmQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq3.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.98; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1689842898; bh=9ch77DVw11CsiWUqrDKHDotKhCLGG96bnG6LHNAQOQc=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature: DKIM-Signature; b=nRQjIvEfKUep4MzTXYHrCNaqsnnX9XGTtCkQZSncBOFazPGUXAiqVAweDWkR6XgV3KQlFmCoi0 D33GIuSIHDrnMCKDGUNaQLwN8JUBFFJ12rrNgC13fQQVKLR2r8iYdqWnRA6AYa/anLNCKQ3G46 Bm97xKAvV/sxGDdrlyQ6f6qmJRPGtF0Uidc8lq45RlBDzCFKFlieHxnv6ZL2NocyT2Ze/YwHFO lRtLmLCoRqUDNyviaWNSENy73zLbWM5RUmsZnoS7qYnI88K4xuapgbwWBkGb8w4gBFnAOa+TY6 aYhjplQBlMCqlJCbHjXbtNYLwo6UP0yR3YTn9gdlnd+aHQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=eKGl9vK8dP4QOX+oI+2OTxIStWet6Kg6Otx2rMAobDo=; b=SjYTv7qwM3tMO9qCHD9GxMsZkL NWZjUMfteuvdDIfEXPBRQlPWTUuDj6ZT//1E9dnL8ln1WlIhsiSyEicRiGJ2oGsdjMSkxwUou3Crv iFKj/+0EKrQELePpfyMfJV6XWQFkCPSyVFfOITywhSEf+ezkN2vTZ+KrYjlHV0Yj7c4oRb4v3rAeo j0w3yJYd27NlIaFIeO2g23WJUacBX91TcozlKkclhQ/jMy/PUJLhSQT14iHIQdEgxFINiGGCv3eFn thPXUbWQr2z5fQUSnR3Pn5ov97JCmdt8xUlk2bkih4cWa7radMw+sOuoemzbWmKimY7KhCIFv+lKw 1JkK5/5w==; Received: by zero.zsh.org with local id 1qMPKb-0000Dr-I6; Thu, 20 Jul 2023 08:48:17 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq3.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.98; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq3.tb.ukmail.iss.as9143.net ([212.54.57.98]:60778) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1qMPJy-000Pt5-4G; Thu, 20 Jul 2023 08:47:40 +0000 Received: from [212.54.57.126] (helo=csmtpq2-prd-nl1-vmo.edge.unified.services) by smtpq3.tb.ukmail.iss.as9143.net with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qMPJx-0008RF-LR for zsh-workers@zsh.org; Thu, 20 Jul 2023 10:47:37 +0200 Received: from oxsmtp2-prd-nl1-vmo.nl1.unified.services ([100.107.83.137]) by csmtpq2-prd-nl1-vmo.edge.unified.services with esmtp (Exim 4.93) (envelope-from ) id 1qMPJx-00E6NR-BP for zsh-workers@zsh.org; Thu, 20 Jul 2023 10:47:37 +0200 Received: from oxbe18-prd-nl1-vmo.nl1.unified.services ([100.107.83.141]) by Virgin Media with ESMTP id MPJxqx5IWH6rPMPJxq942Q; Thu, 20 Jul 2023 10:47:37 +0200 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-workers@zsh.org X-SourceIP: 100.107.83.141 X-CNFS-Analysis: v=2.4 cv=TMiDCXpa c=1 sm=1 tr=0 ts=64b8f4a9 cx=a_exe a=Geqx+NPbHKPVi5Wvcymeew==:117 a=IvlwODmuRu4A:10 a=IkcTkHD0fZMA:10 a=NLZqzBF-AAAA:8 a=c4WtyTE9GzS9xHCQuQYA:9 a=QEXdDO2ut3YA:10 a=HbQOABYz3jhqdZF7JfnK:22 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1689842857; bh=9ch77DVw11CsiWUqrDKHDotKhCLGG96bnG6LHNAQOQc=; h=Date:From:To:In-Reply-To:References:Subject; b=QHopiOGRVDYuVd05oldlR4KcMB9En+A1xg0Uq+cZ2a6/4b5l0LUEeNOf4C6G3DI7g z93EBZ/UwF/b/xhd8likB5AH/VbfCPVMHxPCmb79Sw3ZUzC5VPy2+wtmGhXC3Kd8qe Wjgqsmwd4Yq4maYSI562CS2lCI7KvUC59DL7XbjeQfIsmcY+GG3BZfbMalpyYxGMrb hNSx/ZkY24jVkFh4bXCaPCxVLQEHmrvUuBL7QHOzw1e62615ddrD+P1OkolZxEqARZ ZZCV7B4SUU5+aLJ9ERN5Qt09fa9z0XDEDOQou/iN6n+uV8Jl1+q8lg/hJO+P/uSELt 7VgKYM48y931g== Date: Thu, 20 Jul 2023 09:47:37 +0100 (BST) From: Peter Stephenson To: Johan Grande , zsh-workers@zsh.org Message-ID: <1567526010.959021.1689842857292@mail.virginmedia.com> In-Reply-To: <1570386064.868183.1689688640076@mail.virginmedia.com> References: <0c1f1b1e-7d2b-ec6b-3044-dc25b6d5a4d5@crans.org> <1263859119.226140.1688636640060@mail.virginmedia.com> <1570386064.868183.1689688640076@mail.virginmedia.com> Subject: Re: Failed pipeline doesn't err_exit/return if complex command last MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer X-Originating-IP: 147.161.224.196 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfOkEQMTpjYj3M2W82b1wZl5waDvr2+6iHiAO/MZLPQOkXWmBowST3kUfb5v23Fp3Btmomd9zLQ6FkgnBZv5JqgmMMfHH3hAMZ7e7K5DYpubEMugdsum+ fFSXsCKM0uz1OrudhKm/ahAogRnKVIM+vKg2mgYnaSNoxg3S6eQsddoxa/Muj0TykCiW3SogRXuZSoxUifroMgGgahiTaBU8RkTELEfsLrAaOTK5LD1Hap0B hph5QStNNnwOTa+isP0/npCBx0O1Q8cf38Y+jvX1zoo= X-Seq: 51977 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: > On 18/07/2023 14:57 Peter Stephenson wrote: > > 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. > > 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. Here's the patch with some tests. 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; + } } } diff --git a/Test/E01options.ztst b/Test/E01options.ztst index 533e08773..83f0371a1 100644 --- a/Test/E01options.ztst +++ b/Test/E01options.ztst @@ -1379,6 +1379,64 @@ F:Regression test for workers/41811 >1 >2 + pipefailfn1() { + emulate -L zsh + setopt errreturn pipefail + false | { true; } + print "Shouldn't get here, status $?" + } + pipefailfn1 +1:PIPE_FAIL causes ERR_RETURN with complex end of pipeline: braces + + pipefailfn2() { + emulate -L zsh + setopt errreturn pipefail + false | if true; then true; fi + print "Shouldn't get here, status $?" + } + pipefailfn2 || print Function failed, as expected +0:PIPE_FAIL causes ERR_RETURN with complex end of pipeline: if +>Function failed, as expected + + pipefailfn3() { + emulate -L zsh + setopt errreturn pipefail + false | while true; do break; done + print "Shouldn't get here, status $?" + } + pipefailfn3 || print Function failed, as expected +0:PIPE_FAIL causes ERR_RETURN with complex end of pipeline: while +>Function failed, as expected + + pipefailfn4() { + emulate -L zsh + setopt errreturn pipefail + false | true + print "Shouldn't get here, status $?" + } + pipefailfn4 +1:PIPE_FAIL causes ERR_RETURN in simple case + + pipefailfn5() { + emulate -L zsh + setopt errreturn pipefail + false | { true | true; } + print "Shouldn't get here, status $?" + } + pipefailfn5 || print Function failed as expected +0:PIPE_FAIL causes ERR_RETURN with nested successful pipe +>Function failed as expected + + pipefailfn6() { + emulate -L zsh + setopt errreturn pipefail + false | { false | true; } + print "Shouldn't get here, status $?" + } + pipefailfn6 || print Function failed as expected +0:PIPE_FAIL causes ERR_RETURN with nested failed pipe +>Function failed as expected + for (( i = 0; i < 10; i++ )); do () { print $i