Pattern: Use of -eq
for string
Issue: -
Shells have two sets of comparison operators: for integers (-eq
, -gt
, ...) and strings (=
, >
, ...). You're using an integer comparison with string data.
If you are in fact comparing integers, double check your parameters. Certain mistakes like $$foo
or ${bar}}
can introduce non-numeric characters into otherwise numeric arguments.
Example of incorrect code:
[[ $foo -eq "Y" ]]
Example of correct code:
[[ $foo = "Y" ]]