From c6b3f473a637ae722e6f76319836baec8994a97c Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 18 Jul 2015 11:47:15 -0700 Subject: [PATCH] Created SC2160 (markdown) --- SC2160.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 SC2160.md diff --git a/SC2160.md b/SC2160.md new file mode 100644 index 0000000..a225366 --- /dev/null +++ b/SC2160.md @@ -0,0 +1,33 @@ +## Instead of '[ true ]', just use 'true'. + +### Problematic code: + + if [ true ] + then + echo "always triggers" + fi + +### Correct code: + + if true + then + echo "never triggers" + fi + +### Rationale: + +This is a stylistic suggestion to use `true` instead of `[ true ]`. + +`[ true ]` seems to suggest that the value "true" is somehow relevant to the statement. This is not the case, it doesn't matter. You can replace it with `[ false ]` or `[ wombat ]`, and it will still always be true: + + String | In brackets | Outside brackets + --------+--------------+----------------- + true | true | true + false | true | false + wombat | true | unknown command + +It's therefore better to use it without brackets, so that the "true" actually matters. + +### Exceptions: + +None. \ No newline at end of file