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