=
in [[ ]]
to prevent glob matching.[[ $a = $b ]]
[[ $a = "$b" ]]
When the right-hand side of =
, ==
or
!=
is unquoted in [[ .. ]]
, it will be treated
like a glob.
This has some unexpected consequences like
[[ $var = $var ]]
being false (for var='[a]'
),
or [[ $foo = $bar ]]
giving a different result from
[[ $bar = $foo ]]
.
The most common intention is to compare one variable to another as strings, in which case the right-hand side must be quoted.
If you explicitly want to match against a pattern, you can ignore this warning.
ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.