fix set -e with and/or inside functions regression (LP#1104543)

cause was that use of && or || inside function switched it to xerrok
This commit is contained in:
tg 2013-02-10 23:59:28 +00:00
parent 63cf38eca7
commit fb370a30c6
3 changed files with 22 additions and 8 deletions

21
check.t
View File

@ -1,4 +1,4 @@
# $MirOS: src/bin/mksh/check.t,v 1.591 2013/02/10 23:36:21 tg Exp $
# $MirOS: src/bin/mksh/check.t,v 1.592 2013/02/10 23:59:23 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
@ -29,7 +29,7 @@
# http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
expected-stdout:
@(#)MIRBSD KSH R41 2013/01/19
@(#)MIRBSD KSH R42 2013/02/10
description:
Check version of shell.
stdin:
@ -38,7 +38,7 @@ name: KSH_VERSION
category: shell:legacy-no
---
expected-stdout:
@(#)LEGACY KSH R41 2013/01/19
@(#)LEGACY KSH R42 2013/02/10
description:
Check version of legacy shell.
stdin:
@ -5754,6 +5754,21 @@ expected-stdout:
Stop in WD/zd/a (line 2 of Makefile).
---
name: exit-err-7
description:
"set -e" regression (LP#1104543)
stdin:
set -e
bla() {
[ -x $PWD/nonexistant ] && $PWD/nonexistant
}
echo x
bla
echo y$?
expected-stdout:
x
expected-exit: 1
---
name: exit-enoent-1
description:
SUSv4 says that the shell should exit with 126/127 in some situations

5
exec.c
View File

@ -23,7 +23,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.113 2013/01/19 19:47:10 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.114 2013/02/10 23:59:25 tg Exp $");
#ifndef MKSH_DEFAULT_EXECSHELL
#define MKSH_DEFAULT_EXECSHELL "/bin/sh"
@ -748,8 +748,7 @@ comexec(struct op *t, struct tbl * volatile tp, const char **ap,
e->type = E_FUNC;
if (!(i = kshsetjmp(e->jbuf))) {
/* seems odd to pass XERROK here, but AT&T ksh does */
exstat = execute(tp->val.t, flags & XERROK, xerrok) & 0xFF;
execute(tp->val.t, 0, NULL);
i = LRETURN;
}
kshname = old_kshname;

4
sh.h
View File

@ -164,9 +164,9 @@
#endif
#ifdef EXTERN
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.633 2013/02/10 21:17:07 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/sh.h,v 1.634 2013/02/10 23:59:28 tg Exp $");
#endif
#define MKSH_VERSION "R41 2013/01/19"
#define MKSH_VERSION "R42 2013/02/10"
/* arithmetic types: C implementation */
#if !HAVE_CAN_INTTYPES