Skip to content

Files

Latest commit

 

History

History
31 lines (21 loc) · 583 Bytes

SC2212.md

File metadata and controls

31 lines (21 loc) · 583 Bytes

Pattern: Use of [ ] instead of false

Issue: -

Description

[ ] is a somewhat obscure way of expressing falsehood, and the behavior is likely intended to allow the incorrectly quoted command [ $var ] to still work when the variable is unset.

POSIX has a more descriptive command false for this.

Example of incorrect code:

if [ ]
then
  echo "Temporarily disabled"
fi

Example of correct code:

if false
then
  echo "Temporarily disabled"
fi

Further Reading