]>
Commit | Line | Data |
---|---|---|
deb63bfb | 1 | # $FreeBSD: head/bin/sh/tests/builtins/trap1.0 213738 2010-10-12 18:20:38Z obrien $ |
71aad674 A |
2 | |
3 | test "$(trap 'echo trapped' EXIT; :)" = trapped || exit 1 | |
4 | ||
5 | test "$(trap 'echo trapped' EXIT; /usr/bin/true)" = trapped || exit 1 | |
6 | ||
7 | result=$(${SH} -c 'trap "echo trapped" EXIT; /usr/bin/false') | |
8 | test $? -eq 1 || exit 1 | |
9 | test "$result" = trapped || exit 1 | |
10 | ||
11 | result=$(${SH} -c 'trap "echo trapped" EXIT; exec /usr/bin/false') | |
12 | test $? -eq 1 || exit 1 | |
13 | test -z "$result" || exit 1 | |
14 | ||
15 | result=0 | |
16 | trap 'result=$((result+1))' INT | |
17 | kill -INT $$ | |
18 | test "$result" -eq 1 || exit 1 | |
19 | (kill -INT $$) | |
20 | test "$result" -eq 2 || exit 1 | |
21 | ||
22 | exit 0 |