diff options
author | Klemens Nanni <kn@cvs.openbsd.org> | 2022-10-14 23:51:17 +0000 |
---|---|---|
committer | Klemens Nanni <kn@cvs.openbsd.org> | 2022-10-14 23:51:17 +0000 |
commit | 21d296ceb23eafa45e05e59b22c36cbea0850fa9 (patch) | |
tree | 72281c153c07fccd66ebf9b2904bb3d04e52d755 /regress/bin | |
parent | f8cb8cd4f61f282895564c091ca10449e54d0b60 (diff) |
add two new errexit/trap tests, tweak wording
both pass in bash and ksh93 from ports.
our ksh fails for now, so mark them as expected fail.
Diffstat (limited to 'regress/bin')
-rw-r--r-- | regress/bin/ksh/trap.t | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/regress/bin/ksh/trap.t b/regress/bin/ksh/trap.t index bdef549c4bc..59dde9b160a 100644 --- a/regress/bin/ksh/trap.t +++ b/regress/bin/ksh/trap.t @@ -1,4 +1,4 @@ -# $OpenBSD: trap.t,v 1.2 2022/10/14 22:56:13 kn Exp $ +# $OpenBSD: trap.t,v 1.3 2022/10/14 23:51:16 kn Exp $ # # Check that I/O redirection failure triggers the ERR trap. @@ -49,12 +49,15 @@ expected-exit: e != 0 --- # -# Check that the errexit option does not interfere with running traps. +# Check that the errexit option +# a) does not interfere with running traps and +# b) propagates a non-zero exit status from traps. +# Check that traps are run in the same order in which they were triggered. # name: EXIT-always-runs description: - Check that the EXIT trap runs under errexit even if the ERR trap failed. + Check that EXIT runs under errexit even if ERR failed. arguments: !-e! stdin: trap 'echo ERR ; false' ERR @@ -81,3 +84,35 @@ expected-stdout: EXIT expected-exit: e == 0 --- + + +name: errexit-aborts-EXIT +# XXX remove once bin/ksh/main.c r1.52 is backed out +expected-fail: yes +description: + Check that errexit makes EXIT exit early. +arguments: !-e! +stdin: + trap 'echo ERR' ERR + trap 'false ; echo EXIT' EXIT +expected-stdout: + ERR +expected-exit: e != 0 +--- + + +name: EXIT-triggers-ERR +# XXX remove once bin/ksh/main.c r1.52 is backed out *AND* and a new fix is in +expected-fail: yes +description: + Check that ERR runs under errexit if EXIT failed. +arguments: !-e! +stdin: + trap 'echo ERR' ERR + trap 'echo EXIT ; false' EXIT + true +expected-stdout: + EXIT + ERR +expected-exit: e != 0 + --- |