Skip to content
Vidar Holen edited this page Sep 8, 2020 · 1 revision

In POSIX sh, using lower/mixed case for signal names is undefined.

Problematic code:

trap 'handle_sigint' int

Correct code:

trap 'handle_sigint' INT

Rationale:

POSIX requires that signal names be given in uppercase:

The condition can be EXIT, 0 (equivalent to EXIT), or a signal specified using a symbolic name, without the SIG prefix, as listed in the tables of signal names in the <signal.h> header defined in XBD Headers; for example, HUP, INT, QUIT, TERM. Implementations may permit names with the SIG prefix or ignore case in signal names as an extension.

Exceptions:

None

Related resources:

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally