The trap shell built-in supports numbers (0, 1, 2, 3, 15, etc), long names (EXIT, SIGHUP, SIGINT, SIGQUIT, SIGTERM, etc), and short names (EXIT, HUP, INT, QUIT, TERM, etc). Use long names:
trap "echo EXIT" EXIT
trap "echo received hangup signal" SIGHUP
trap "echo received interrupt signal" SIGINT
trap "echo received quit signal" SIGQUIT
trap "echo received terminate signal" SIGTERM
Copy link