From 56bdf24e548ad331214a66ba35cbf862eacc661a Mon Sep 17 00:00:00 2001 From: tg Date: Sun, 2 Oct 2016 22:21:47 +0000 Subject: [PATCH] fix error propagation in TAND/TOR constructs, noted by Martijn Dekker MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit still a bit unsure about the whole XERROK and *xerrok stuff, but… it seems to work --- check.t | 19 ++++++++++++++++--- exec.c | 4 ++-- sh.h | 4 ++-- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/check.t b/check.t index f78c266..78c1223 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.753 2016/09/01 12:59:05 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.754 2016/10/02 22:21:43 tg Exp $ # -*- mode: sh -*- #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @@ -30,7 +30,7 @@ # (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date expected-stdout: - @(#)MIRBSD KSH R53 2016/09/01 + @(#)MIRBSD KSH R53 2016/10/02 description: Check version of shell. stdin: @@ -39,7 +39,7 @@ name: KSH_VERSION category: shell:legacy-no --- expected-stdout: - @(#)LEGACY KSH R53 2016/09/01 + @(#)LEGACY KSH R53 2016/10/02 description: Check version of legacy shell. stdin: @@ -7152,6 +7152,19 @@ stdin: db_go exit 0 --- +name: exit-err-9 +description: + "set -e" versus bang pipelines +stdin: + set -e + ! false | false + echo 1 ok + ! false && false + echo 2 wrong +expected-stdout: + 1 ok +expected-exit: 1 +--- name: exit-enoent-1 description: SUSv4 says that the shell should exit with 126/127 in some situations diff --git a/exec.c b/exec.c index ec28d74..11c8a80 100644 --- a/exec.c +++ b/exec.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.181 2016/09/01 12:59:09 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.182 2016/10/02 22:21:46 tg Exp $"); #ifndef MKSH_DEFAULT_EXECSHELL #define MKSH_DEFAULT_EXECSHELL MKSH_UNIXROOT "/bin/sh" @@ -282,7 +282,7 @@ execute(struct op * volatile t, case TOR: case TAND: - rv = execute(t->left, XERROK, xerrok); + rv = execute(t->left, XERROK, NULL); if ((rv == 0) == (t->type == TAND)) rv = execute(t->right, flags & XERROK, xerrok); else { diff --git a/sh.h b/sh.h index 5b058f3..7c7df8f 100644 --- a/sh.h +++ b/sh.h @@ -175,9 +175,9 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.788 2016/09/01 12:59:11 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.789 2016/10/02 22:21:47 tg Exp $"); #endif -#define MKSH_VERSION "R53 2016/09/01" +#define MKSH_VERSION "R53 2016/10/02" /* arithmetic types: C implementation */ #if !HAVE_CAN_INTTYPES