Created SC2107 (markdown)

koalaman
2015-08-15 22:14:45 -07:00
parent 448233b881
commit 5d456ad3ff

17
SC2107.md Normal file

@@ -0,0 +1,17 @@
## Instead of [ a && b ], use [ a ] && [ b ].
### Problematic code:
[ "$1" = "-v" && -z "$2" ]
### Correct code:
[ "$1" = "-v" ] && [ -z "$2" ]
### Rationale:
`&&` can not be used in a `[ .. ]` test expression. Instead, make two `[ .. ]` expressions and put the `&&` between them.
### Exceptions:
None.