From 5d456ad3ff143bf19930be86f9233a0cb5b42c80 Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 15 Aug 2015 22:14:45 -0700 Subject: [PATCH] Created SC2107 (markdown) --- SC2107.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 SC2107.md 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