Skip to content

Files

Latest commit

 

History

History
25 lines (15 loc) · 622 Bytes

SC2130.md

File metadata and controls

25 lines (15 loc) · 622 Bytes

Pattern: Use of -eq for string

Issue: -

Description

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" ]]

Further Reading