xref: /freebsd/bin/sh/tests/builtins/trap16.0 (revision eda14cbc264d6969b02f2b1994cef11148e914f1)
1# $FreeBSD$
2
3traps=$(${SH} -c 'trap "echo bad" 0; trap - 0; trap')
4[ -z "$traps" ] || exit 1
5traps=$(${SH} -c 'trap "echo bad" 0; trap "" 0; trap')
6expected_traps=$(${SH} -c 'trap "" EXIT; trap')
7[ "$traps" = "$expected_traps" ] || exit 2
8traps=$(${SH} -c 'trap "echo bad" 0; trap 0; trap')
9[ -z "$traps" ] || exit 3
10traps=$(${SH} -c 'trap "echo bad" 0; trap -- 0; trap')
11[ -z "$traps" ] || exit 4
12traps=$(${SH} -c 'trap "echo bad" 0 1 2; trap - 0 1 2; trap')
13[ -z "$traps" ] || exit 5
14traps=$(${SH} -c 'trap "echo bad" 0 1 2; trap "" 0 1 2; trap')
15expected_traps=$(${SH} -c 'trap "" EXIT HUP INT; trap')
16[ "$traps" = "$expected_traps" ] || exit 6
17traps=$(${SH} -c 'trap "echo bad" 0 1 2; trap 0 1 2; trap')
18[ -z "$traps" ] || exit 7
19traps=$(${SH} -c 'trap "echo bad" 0 1 2; trap -- 0 1 2; trap')
20[ -z "$traps" ] || exit 8
21