Skip to content

Latest commit

 

History

History
33 lines (23 loc) · 600 Bytes

SC3014.md

File metadata and controls

33 lines (23 loc) · 600 Bytes

Pattern: Use of undefined == in place of =

Issue: -

Description

== is used for equality comparison in C-like languages, and is also supported by bash and ksh in [ .. ] and test expressions.

sh and dash only supports = for equality comparison, so use that instead.

Example of incorrect code:

#!/bin/sh
if [ $1 == "-n" ]
then
  dry_run=1
fi

Example of correct code:

#!/bin/sh
if [ $1 = "-n" ]
then
  dry_run=1
fi

Further Reading