Skip to content

Files

Latest commit

 

History

History
43 lines (26 loc) · 683 Bytes

SC1097.md

File metadata and controls

43 lines (26 loc) · 683 Bytes

Pattern: Unexpected == in shell script

Issue: -

Description

== is used in an unexpected way. The two most common reasons for this is:

  • You wanted to assign a value but accidentally used == instead of =.

  • You wanted to compare two values, but neglected to use [ .. ] or [[ .. ]].

Example of incorrect code:

var==value

Example of correct code:

Assignment:

var=value

Comparison:

[ "$var" = value ]

Exceptions

If you wanted to assign a literal equals sign, use quotes to make this clear:

var="=sum(A1:A10)"

Further Reading