diff --git a/check.t b/check.t index 8cce341..ee7b6bb 100644 --- a/check.t +++ b/check.t @@ -1,4 +1,4 @@ -# $MirOS: src/bin/mksh/check.t,v 1.584 2013/01/01 20:45:00 tg Exp $ +# $MirOS: src/bin/mksh/check.t,v 1.585 2013/01/01 22:23:14 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 $ @@ -5824,20 +5824,23 @@ expected-exit: 9 name: exit-trap-2 description: Check that ERR and EXIT traps are run just like ksh93 does. - GNU bash does not run ERtrap in eval-undef. + GNU bash does not run ERtrap in ±e eval-undef but runs it + twice (bug?) in +e eval-false, so does ksh93 (bug?), which + also has a bug to continue execution (echoing "and out" and + returning 0) in +e eval-undef. file-setup: file 644 "x" v=; unset v trap 'echo EXtrap' EXIT trap 'echo ERtrap' ERR - set -e - echo "and run $1" - eval $1 + set $1 + echo "and run $2" + eval $2 echo and out file-setup: file 644 "xt" v=; unset v trap 'echo EXtrap' EXIT trap 'echo ERtrap' ERR - set -e + set $1 echo 'and run true' true echo and out @@ -5845,7 +5848,7 @@ file-setup: file 644 "xf" v=; unset v trap 'echo EXtrap' EXIT trap 'echo ERtrap' ERR - set -e + set $1 echo 'and run false' false echo and out @@ -5853,7 +5856,7 @@ file-setup: file 644 "xu" v=; unset v trap 'echo EXtrap' EXIT trap 'echo ERtrap' ERR - set -e + set $1 echo 'and run ${v?}' ${v?} echo and out @@ -5868,21 +5871,36 @@ stdin: -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \ -e "s^${__progname%.exe}\.*e*x*e*: \[[0-9]*]PROG" } - echo : - runtest x true + xe=-e + echo : $xe + runtest x $xe true echo = eval-true $( #endif -__RCSID("$MirOS: src/bin/mksh/main.c,v 1.250 2013/01/01 20:45:03 tg Exp $"); +__RCSID("$MirOS: src/bin/mksh/main.c,v 1.251 2013/01/01 22:23:16 tg Exp $"); extern char **environ; @@ -872,20 +872,6 @@ shell(Source * volatile s, volatile bool toplevel) void unwind(int i) { - /* ordering for EXIT vs ERR is a bit odd (this is what AT&T ksh does) */ - if (i == LEXIT || (Flag(FERREXIT) == 1 && - (i == LERROR || i == LINTR) && sigtraps[ksh_SIGEXIT].trap)) { - ++trap_nested; - runtrap(&sigtraps[ksh_SIGEXIT], trap_nested == 1); - --trap_nested; - i = LLEAVE; - } else if (Flag(FERREXIT) == 1 && (i == LERROR || i == LINTR)) { - ++trap_nested; - runtrap(&sigtraps[ksh_SIGERR], trap_nested == 1); - --trap_nested; - i = LLEAVE; - } - /* * This is a kludge. We need to restore everything that was * changed in the new environment, see cid 1005090337C7A669439 @@ -902,6 +888,20 @@ unwind(int i) Flag(FERREXIT) &= ~0x80; } + /* ordering for EXIT vs ERR is a bit odd (this is what AT&T ksh does) */ + if (i == LEXIT || + ((i == LERROR || i == LINTR) && sigtraps[ksh_SIGEXIT].trap)) { + ++trap_nested; + runtrap(&sigtraps[ksh_SIGEXIT], trap_nested == 1); + --trap_nested; + i = LLEAVE; + } else if (Flag(FERREXIT) == 1 && (i == LERROR || i == LINTR)) { + ++trap_nested; + runtrap(&sigtraps[ksh_SIGERR], trap_nested == 1); + --trap_nested; + i = LLEAVE; + } + while (/* CONSTCOND */ 1) { switch (e->type) { case E_PARSE: