mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC3048 (markdown)
29
SC3048.md
Normal file
29
SC3048.md
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
## In POSIX sh, prefixing signal names with 'SIG' is undefined.
|
||||||
|
|
||||||
|
(or "In dash, ... is not supported." when using `dash`)
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
trap 'handle_interrupt' SIGINT
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
trap 'handle_interrupt' INT
|
||||||
|
```
|
||||||
|
|
||||||
|
### Rationale:
|
||||||
|
|
||||||
|
POSIX does not allow specifying the "SIG" prefix of a signal name like "INT". Bash and Ksh supports this as an extension.
|
||||||
|
|
||||||
|
Simply remove the "SIG" from the signal name.
|
||||||
|
|
||||||
|
### Exceptions:
|
||||||
|
|
||||||
|
None
|
||||||
|
|
||||||
|
### Related resources:
|
||||||
|
|
||||||
|
* Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!
|
Reference in New Issue
Block a user