xref: /freebsd/bin/sh/tests/builtins/trap1.0 (revision 55141f2c8991b2a6adbf30bb0fe3e6cbc303f06d)
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