You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prefer == over = for string comparisons in Bash tests.
Optional - require-double-equals
This is an optional rule, which means that it has a special "long name" and is not enabled by default. See the optional page for more details. In short, you have to enable it with the long name instead of the "SC" code like you would with a normal rule:
.shellcheckrc
enable=require-double-equals # SC2338
Problematic code:
[[ "$x"="$y" ]]
Correct code:
[[ "$x"=="$y" ]]
Rationale:
ShellCheck has been explicitly asked to warn about uses of = for string comparisons in Bash tests in favor of ==.
Both = and == can be used for string equality comparisons in Bash. However, == more clearly communicates that an equality comparison is being performed, since a single = is commonly associated with assignment in programming languages.
Using == can therefore make the intent of the test easier to recognize at a glance.
Exceptions:
This check is not enabled by default, and may have been turned on for your current project by someone who wants it enforced. You can still ignore it with a directive.
This suggestion only triggers for Bash scripts. It does not trigger for Sh or Ksh scripts, even when explicitly enabled.