From cf80c5a1055346aaa67215fd03edee72866532cb Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 18 Jul 2015 11:30:29 -0700 Subject: [PATCH] Created SC2158 (markdown) --- SC2158.md | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 SC2158.md diff --git a/SC2158.md b/SC2158.md new file mode 100644 index 0000000..fd3c2d8 --- /dev/null +++ b/SC2158.md @@ -0,0 +1,25 @@ +## [ false ] is true. Remove the brackets + +### Problematic code: + + if [ false ] + then + echo "triggers anyways" + fi + +### Correct code: + + if false + then + echo "never triggers" + fi + +### Rationale: + +`[ str ]` checks whether `str` is non-empty. It doesn't matter if `str` is `false`, it will still be evaluated for non-emptyness. + +Instead, use the command `false` which -- as the manual puts it -- does nothing, unsuccessfully. + +### Exceptions: + +None \ No newline at end of file