mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2108 (markdown)
17
SC2108.md
Normal file
17
SC2108.md
Normal file
@@ -0,0 +1,17 @@
|
||||
## In [\[..]], use && instead of -a.
|
||||
|
||||
### Problematic code:
|
||||
|
||||
[[ "$1" = "-v" -a -z "$2" ]]
|
||||
|
||||
### Correct code:
|
||||
|
||||
[[ "$1" = "-v" && -z "$2" ]]
|
||||
|
||||
### Rationale:
|
||||
|
||||
`-a` for logical AND is not supported in a `[[ .. ]]` expression. Use `&&` instead.
|
||||
|
||||
### Exceptions:
|
||||
|
||||
None.
|
Reference in New Issue
Block a user