mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2172 (markdown)
22
SC2172.md
Normal file
22
SC2172.md
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
## Trapping signals by number is not well defined. Prefer signal names.
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
trap myfunc 28
|
||||||
|
```
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
trap myfunc WINCH
|
||||||
|
```
|
||||||
|
### Rationale:
|
||||||
|
|
||||||
|
Signal numbers can vary between platforms. Prefer signal names, which are fixed.
|
||||||
|
|
||||||
|
Signal numbers 1, 2, 3, 6, 9, 14 and 15 are specified as parts of the optional POSIX XSI and ShellCheck will not warn about these.
|
||||||
|
|
||||||
|
### Exceptions:
|
||||||
|
|
||||||
|
None.
|
Reference in New Issue
Block a user