mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2109 (markdown)
17
SC2109.md
Normal file
17
SC2109.md
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
## Instead of [ a || b ], use [ a ] || [ b ].
|
||||||
|
|
||||||
|
### Problematic code:
|
||||||
|
|
||||||
|
[ "$1" = "-v" || "$1" = "-help" ]
|
||||||
|
|
||||||
|
### Correct code:
|
||||||
|
|
||||||
|
[ "$1" = "-v" ] || [ "$1" = "-help" ]
|
||||||
|
|
||||||
|
### Rationale:
|
||||||
|
|
||||||
|
`||` can not be used in a `[ .. ]` test expression. Instead, make two `[ .. ]` expressions and put the `||` between them.
|
||||||
|
|
||||||
|
### Exceptions:
|
||||||
|
|
||||||
|
None.
|
Reference in New Issue
Block a user