Skip to content
Joachim Ansorg edited this page Nov 12, 2021 · 4 revisions

-eq is for integer comparisons. Use = instead.

Problematic code:

[[ $foo -eq "Y" ]]

Correct code:

[[ $foo = "Y" ]]

Rationale:

Shells have two sets of comparison operators: for integers (-eq, -gt, ...) and strings (=, >, ...). ShellCheck has noticed that 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.

Exceptions

None.

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature guerraart8 to find a specific , or see Checks.

Clone this wiki locally