xref: /freebsd/bin/sh/tests/builtins/trap1.0 (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1
2test "$(trap 'echo trapped' EXIT; :)" = trapped || exit 1
3
4test "$(trap 'echo trapped' EXIT; /usr/bin/true)" = trapped || exit 1
5
6result=$(${SH} -c 'trap "echo trapped" EXIT; /usr/bin/false')
7test $? -eq 1 || exit 1
8test "$result" = trapped || exit 1
9
10result=$(${SH} -c 'trap "echo trapped" EXIT; exec /usr/bin/false')
11test $? -eq 1 || exit 1
12test -z "$result" || exit 1
13
14result=0
15trap 'result=$((result+1))' INT
16kill -INT $$
17test "$result" -eq 1 || exit 1
18(kill -INT $$)
19test "$result" -eq 2 || exit 1
20
21exit 0
22