Skip to content

Files

Latest commit

 

History

History
39 lines (27 loc) · 619 Bytes

SC2283.md

File metadata and controls

39 lines (27 loc) · 619 Bytes

Pattern: Missing use of [] to compare values

Issue: -

Description

If this was supposed to be a comparison, use square brackets: [ "$var" = value ]

If this was supposed to be an assignment, remove spaces around =: var=value.

Example of incorrect code:

# Assignment
var = value

# Comparison
if $var = value
then
  echo "Match"
fi

Example of correct code:

# Assignment
var=value

# Comparison
if [ "$var" = value ]
then
  echo "Match"
fi

Further Reading