Created SC2158 (markdown)

koalaman
2015-07-18 11:30:29 -07:00
parent abdb4c4bf7
commit cf80c5a105

25
SC2158.md Normal file

@@ -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