HomeFreeBSD

sh: Fix the trap builtin to be POSIX-compliant for 'trap exit SIG' and 'trap n…

Description

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

Event Timeline