Pattern: Use of undefined ==
in place of =
Issue: -
==
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