blob: 8cead8bcd64edd64265d8af94ce7c27bf4aed96b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# $OpenBSD: trap.t,v 1.4 2022/10/15 15:29:45 kn Exp $
#
# Check that I/O redirection failure triggers the ERR trap.
# stderr patterns are minimal to match all of bash, ksh and ksh93.
# Try writing the root directory to guarantee EISDIR.
#
name: failed-redirect-triggers-ERR-restricted
description:
Check that restricted mode prevents valid redirections that may write.
arguments: !-r!
stdin:
trap 'echo ERR' ERR
true >/dev/null
expected-stdout:
ERR
expected-stderr-pattern:
/restricted/
expected-exit: e != 0
---
name: failed-redirect-triggers-ERR-command
description:
Redirect standard output for a single command.
stdin:
trap 'echo ERR' ERR
true >/
expected-stdout:
ERR
expected-stderr-pattern:
/Is a directory/
expected-exit: e != 0
---
name: failed-redirect-triggers-ERR-permanent
description:
Permanently redirect standard output of the shell without execution.
stdin:
trap 'echo ERR' ERR
exec >/
expected-stdout:
ERR
expected-stderr-pattern:
/Is a directory/
expected-exit: e != 0
---
#
# 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
# XXX remove once bin/ksh/main.c r1.52 is backed out *AND* a new fix is in
# XXX enable once bin/ksh/main.c r1.52 is backed out
#expected-fail: yes
description:
Check that EXIT runs under errexit even if ERR failed.
arguments: !-e!
stdin:
trap 'echo ERR ; false' ERR
trap 'echo EXIT' EXIT
false
expected-stdout:
ERR
EXIT
expected-exit: e != 0
---
name: signal-handling-is-no-error
description:
Check that gracefully handling a signal is not treated as error.
arguments: !-e!
stdin:
trap 'echo ERR' ERR
trap 'echo EXIT' EXIT
trap 'echo USR1' USR1
kill -USR1 $$
expected-stdout:
USR1
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
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
---
|