Skip to content

Files

Latest commit

 

History

History
30 lines (18 loc) · 811 Bytes

SC2053.md

File metadata and controls

30 lines (18 loc) · 811 Bytes

Pattern: Use of unquoted right-hand side of =, == or != in [[ .. ]]

Issue: -

Description

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.

Example of incorrect code:

[[ $a = $b ]]

Example of correct code:

[[ $a = "$b" ]]

Exceptions

If you explicitly want to match against a pattern, you can ignore this warning.

Further Reading