From cb9a5dfcd77d227db544f82fed2c44b044a5c470 Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Mon, 7 Sep 2020 20:57:11 -0700 Subject: [PATCH] Created SC3049 (markdown) --- SC3049.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 SC3049.md diff --git a/SC3049.md b/SC3049.md new file mode 100644 index 0000000..670c04b --- /dev/null +++ b/SC3049.md @@ -0,0 +1,28 @@ +## In POSIX sh, using lower/mixed case for signal names is undefined. + +### Problematic code: + +```sh +trap 'handle_sigint' int +``` + +### Correct code: + +```sh +trap 'handle_sigint' INT +``` + +### Rationale: + +POSIX requires that signal names [be given in uppercase](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_28): + +>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 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!