fix error propagation in TAND/TOR constructs, noted by Martijn Dekker

still a bit unsure about the whole XERROK and *xerrok stuff, but…
it seems to work
This commit is contained in:
tg 2016-10-02 22:21:47 +00:00
parent 9c602791b2
commit 56bdf24e54
3 changed files with 20 additions and 7 deletions

19
check.t
View File

@ -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

4
exec.c
View File

@ -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 {

4
sh.h
View File

@ -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