freebsd-nq/bin/sh/tests/builtins/trap15.0
Bryan Drewery a59f817491 sh: Fix the trap builtin to be POSIX-compliant for 'trap exit SIG' and 'trap n n...'.
The parser considered 'trap exit INT' to reset the default for both EXIT and
INT. This beahvior is not POSIX compliant. This was avoided if a value was
specified for 'exit', but then disallows exiting with the signal received. A
possible workaround is using ' exit'.

However POSIX does allow this type of behavior if the parameters are all
integers. Fix the handling for this and clarify its support in the manpage
since it is specifically allowed by POSIX.

Differential Revision:	https://reviews.freebsd.org/D2325
Reviewed by:	jilles
MFC after:	2 weeks
2015-04-18 23:49:57 +00:00

6 lines
113 B
Plaintext

# $FreeBSD$
(${SH} -c 'term(){ exit 5;}; trap term TERM; kill -TERM $$') &
wait >/dev/null 2>&1 $!
[ $? -eq 5 ]