Skip to content

unquoted-pattern

Shellsuspiciousno fixdefault: offshell/shellcheck

Reports a ==, != or = in [[ ]] whose right side is an unquoted expansion.

In [[ ]] the right side is a pattern, so a * or ? in the value of $b in [[ $a == $b ]] matches anything, and the test is not a comparison of two strings.

To fix, quote the right side: [[ $a == "$b" ]].

Reported
...
PGHOST=db psql
...
unset "words[0]"
[[ $a == $b ]]
[[ $a == "$b" ]]
...
x=$(echo "a" | tr a b)
...
shell:
lint:
rules:
unquoted-pattern: warn # off (default), warn, error

Enabled by the presets: shell/shellcheck.

Suppress one line with sudsy-disable-next-line unquoted-pattern in a comment of the file’s language.

The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.

Tool Rule Match What differs
shellcheck SC2053 partial Only an unquoted expansion on the right of ==, != or = in [[ ]].