fix the set +e cases, too
This commit is contained in:
parent
72a748c891
commit
d5ba31fd86
78
check.t
78
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: 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: 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 $
|
# $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
|
name: exit-trap-2
|
||||||
description:
|
description:
|
||||||
Check that ERR and EXIT traps are run just like ksh93 does.
|
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"
|
file-setup: file 644 "x"
|
||||||
v=; unset v
|
v=; unset v
|
||||||
trap 'echo EXtrap' EXIT
|
trap 'echo EXtrap' EXIT
|
||||||
trap 'echo ERtrap' ERR
|
trap 'echo ERtrap' ERR
|
||||||
set -e
|
set $1
|
||||||
echo "and run $1"
|
echo "and run $2"
|
||||||
eval $1
|
eval $2
|
||||||
echo and out
|
echo and out
|
||||||
file-setup: file 644 "xt"
|
file-setup: file 644 "xt"
|
||||||
v=; unset v
|
v=; unset v
|
||||||
trap 'echo EXtrap' EXIT
|
trap 'echo EXtrap' EXIT
|
||||||
trap 'echo ERtrap' ERR
|
trap 'echo ERtrap' ERR
|
||||||
set -e
|
set $1
|
||||||
echo 'and run true'
|
echo 'and run true'
|
||||||
true
|
true
|
||||||
echo and out
|
echo and out
|
||||||
@ -5845,7 +5848,7 @@ file-setup: file 644 "xf"
|
|||||||
v=; unset v
|
v=; unset v
|
||||||
trap 'echo EXtrap' EXIT
|
trap 'echo EXtrap' EXIT
|
||||||
trap 'echo ERtrap' ERR
|
trap 'echo ERtrap' ERR
|
||||||
set -e
|
set $1
|
||||||
echo 'and run false'
|
echo 'and run false'
|
||||||
false
|
false
|
||||||
echo and out
|
echo and out
|
||||||
@ -5853,7 +5856,7 @@ file-setup: file 644 "xu"
|
|||||||
v=; unset v
|
v=; unset v
|
||||||
trap 'echo EXtrap' EXIT
|
trap 'echo EXtrap' EXIT
|
||||||
trap 'echo ERtrap' ERR
|
trap 'echo ERtrap' ERR
|
||||||
set -e
|
set $1
|
||||||
echo 'and run ${v?}'
|
echo 'and run ${v?}'
|
||||||
${v?}
|
${v?}
|
||||||
echo and out
|
echo and out
|
||||||
@ -5868,21 +5871,36 @@ stdin:
|
|||||||
-e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
|
-e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
|
||||||
-e "s^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]PROG"
|
-e "s^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]PROG"
|
||||||
}
|
}
|
||||||
echo :
|
xe=-e
|
||||||
runtest x true
|
echo : $xe
|
||||||
|
runtest x $xe true
|
||||||
echo = eval-true $(<rc) .
|
echo = eval-true $(<rc) .
|
||||||
runtest x false
|
runtest x $xe false
|
||||||
echo = eval-false $(<rc) .
|
echo = eval-false $(<rc) .
|
||||||
runtest x '${v?}'
|
runtest x $xe '${v?}'
|
||||||
echo = eval-undef $(<rc) .
|
echo = eval-undef $(<rc) .
|
||||||
runtest xt
|
runtest xt $xe
|
||||||
echo = noeval-true $(<rc) .
|
echo = noeval-true $(<rc) .
|
||||||
runtest xf
|
runtest xf $xe
|
||||||
echo = noeval-false $(<rc) .
|
echo = noeval-false $(<rc) .
|
||||||
runtest xu
|
runtest xu $xe
|
||||||
|
echo = noeval-undef $(<rc) .
|
||||||
|
xe=+e
|
||||||
|
echo : $xe
|
||||||
|
runtest x $xe true
|
||||||
|
echo = eval-true $(<rc) .
|
||||||
|
runtest x $xe false
|
||||||
|
echo = eval-false $(<rc) .
|
||||||
|
runtest x $xe '${v?}'
|
||||||
|
echo = eval-undef $(<rc) .
|
||||||
|
runtest xt $xe
|
||||||
|
echo = noeval-true $(<rc) .
|
||||||
|
runtest xf $xe
|
||||||
|
echo = noeval-false $(<rc) .
|
||||||
|
runtest xu $xe
|
||||||
echo = noeval-undef $(<rc) .
|
echo = noeval-undef $(<rc) .
|
||||||
expected-stdout:
|
expected-stdout:
|
||||||
:
|
: -e
|
||||||
and run true
|
and run true
|
||||||
and out
|
and out
|
||||||
EXtrap
|
EXtrap
|
||||||
@ -5908,6 +5926,34 @@ expected-stdout:
|
|||||||
xu: v: parameter null or not set
|
xu: v: parameter null or not set
|
||||||
EXtrap
|
EXtrap
|
||||||
= noeval-undef 1 .
|
= noeval-undef 1 .
|
||||||
|
: +e
|
||||||
|
and run true
|
||||||
|
and out
|
||||||
|
EXtrap
|
||||||
|
= eval-true 0 .
|
||||||
|
and run false
|
||||||
|
ERtrap
|
||||||
|
and out
|
||||||
|
EXtrap
|
||||||
|
= eval-false 0 .
|
||||||
|
and run ${v?}
|
||||||
|
x: v: parameter null or not set
|
||||||
|
ERtrap
|
||||||
|
EXtrap
|
||||||
|
= eval-undef 1 .
|
||||||
|
and run true
|
||||||
|
and out
|
||||||
|
EXtrap
|
||||||
|
= noeval-true 0 .
|
||||||
|
and run false
|
||||||
|
ERtrap
|
||||||
|
and out
|
||||||
|
EXtrap
|
||||||
|
= noeval-false 0 .
|
||||||
|
and run ${v?}
|
||||||
|
xu: v: parameter null or not set
|
||||||
|
EXtrap
|
||||||
|
= noeval-undef 1 .
|
||||||
---
|
---
|
||||||
name: test-stlt-1
|
name: test-stlt-1
|
||||||
description:
|
description:
|
||||||
|
30
main.c
30
main.c
@ -34,7 +34,7 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#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;
|
extern char **environ;
|
||||||
|
|
||||||
@ -872,20 +872,6 @@ shell(Source * volatile s, volatile bool toplevel)
|
|||||||
void
|
void
|
||||||
unwind(int i)
|
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
|
* This is a kludge. We need to restore everything that was
|
||||||
* changed in the new environment, see cid 1005090337C7A669439
|
* changed in the new environment, see cid 1005090337C7A669439
|
||||||
@ -902,6 +888,20 @@ unwind(int i)
|
|||||||
Flag(FERREXIT) &= ~0x80;
|
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) {
|
while (/* CONSTCOND */ 1) {
|
||||||
switch (e->type) {
|
switch (e->type) {
|
||||||
case E_PARSE:
|
case E_PARSE:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user