xref: /freebsd/bin/sh/tests/builtins/trap16.0 (revision 193d9e768ba63fcfb187cfd17f461f7d41345048)
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