From 73edeaa8ec17e80f66bed82607af2e73fae41b7a Mon Sep 17 00:00:00 2001 From: tg Date: Tue, 10 Jun 2014 22:17:10 +0000 Subject: [PATCH] =?UTF-8?q?fix=20=E2=80=9Cset=20-o=20pipefail=E2=80=9D=20w?= =?UTF-8?q?/o=20PIPESTATUS,=20and=20PIPESTATUS=20inside=20COMSUBs=20and=20?= =?UTF-8?q?other=20sequences?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- check.t | 8 +++++--- exec.c | 4 ++-- jobs.c | 13 +++++++++++-- sh.h | 4 ++-- 4 files changed, 20 insertions(+), 9 deletions(-) diff --git a/check.t b/check.t index a19e02e..be6cdb6 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.651 2014/06/09 13:25:50 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.652 2014/06/10 22:17:07 tg Exp $ # OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44 #- # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, @@ -27,7 +27,7 @@ # http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD expected-stdout: - @(#)MIRBSD KSH R50 2014/06/09 + @(#)MIRBSD KSH R50 2014/06/10 description: Check version of shell. stdin: @@ -36,7 +36,7 @@ name: KSH_VERSION category: shell:legacy-no --- expected-stdout: - @(#)LEGACY KSH R50 2014/06/09 + @(#)LEGACY KSH R50 2014/06/10 description: Check version of legacy shell. stdin: @@ -6513,6 +6513,7 @@ stdin: echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" . echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" . echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" . + echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" . expected-stdout: 1 42 . 2 0 . @@ -6522,6 +6523,7 @@ expected-stdout: 6 1 . 7 42 . 8 0 . + 9 42 . --- name: persist-history-1 description: diff --git a/exec.c b/exec.c index 3ad792b..db2373f 100644 --- a/exec.c +++ b/exec.c @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.130 2014/05/27 13:22:43 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.131 2014/06/10 22:17:08 tg Exp $"); #ifndef MKSH_DEFAULT_EXECSHELL #define MKSH_DEFAULT_EXECSHELL "/bin/sh" @@ -462,7 +462,7 @@ execute(struct op * volatile t, if (vp_pipest->flag & INT_L) { unset(vp_pipest, 1); vp_pipest->flag = DEFINED | ISSET | INTEGER | RDONLY | - ARRAY | INT_U; + ARRAY | INT_U | INT_L; vp_pipest->val.i = rv; } diff --git a/jobs.c b/jobs.c index 668491a..0216a34 100644 --- a/jobs.c +++ b/jobs.c @@ -2,7 +2,7 @@ /*- * Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2011, - * 2012, 2013 + * 2012, 2013, 2014 * Thorsten Glaser * * Provided that these terms and disclaimer and all copyright notices @@ -23,7 +23,7 @@ #include "sh.h" -__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.103 2013/11/30 17:41:35 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/jobs.c,v 1.104 2014/06/10 22:17:09 tg Exp $"); #if HAVE_KILLPG #define mksh_killpg killpg @@ -1270,6 +1270,15 @@ j_waitj(Job *j, rv = vp->val.i; p = p->next; } + } else if (Flag(FPIPEFAIL) && (j->proc_list != NULL)) { + Proc *p = j->proc_list; + int i; + + while (p != NULL) { + if ((i = proc_errorlevel(p))) + rv = i; + p = p->next; + } } if (!(flags & JW_ASYNCNOTIFY) diff --git a/sh.h b/sh.h index 50ac350..01b9df6 100644 --- a/sh.h +++ b/sh.h @@ -169,9 +169,9 @@ #endif #ifdef EXTERN -__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.687 2014/06/09 13:25:53 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.688 2014/06/10 22:17:10 tg Exp $"); #endif -#define MKSH_VERSION "R50 2014/06/09" +#define MKSH_VERSION "R50 2014/06/10" /* arithmetic types: C implementation */ #if !HAVE_CAN_INTTYPES