diff --git a/SC2107.md b/SC2107.md new file mode 100644 index 0000000..2fe7f26 --- /dev/null +++ b/SC2107.md @@ -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. \ No newline at end of file