From 16d16a15360f395bdb30f5927a7e5f19738d44f3 Mon Sep 17 00:00:00 2001 From: koalaman Date: Wed, 5 Mar 2014 13:02:46 -0800 Subject: [PATCH] Created SC2077 (markdown) --- SC2077.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 SC2077.md diff --git a/SC2077.md b/SC2077.md new file mode 100644 index 0000000..88d2983 --- /dev/null +++ b/SC2077.md @@ -0,0 +1,21 @@ +## You need spaces around the comparison operator. + +### Problematic code: + + [[ 0=1 ]] + +### Correct code: + + [[ 0 = 1 ]] + +### Rationale: + +`[[ 0 = 1 ]]` means "check if 0 and 1 are equal". + +`[[ str ]]` is short form for `[[ -n str ]]`, and means "check if `str` is non-empty". It doesn't matter if `str` happens to contain `0=1`. + +Always use spaces around the comparison operator in `[..]` and `[[..]]`, otherwise it won't be recognized as an operator. + +### Contraindications + +None. \ No newline at end of file