unquoted-pattern
What it does
Section titled “What it does”Reports a ==, != or = in [[ ]] whose right side is an unquoted expansion.
Why it matters
Section titled “Why it matters”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" ]].
Example
Section titled “Example”...PGHOST=db psql...unset "words[0]"[[ $a == $b ]][[ $a == "$b" ]]...x=$(echo "a" | tr a b)...Configuration
Section titled “Configuration”shell: lint: rules: unquoted-pattern: warn # off (default), warn, errorEnabled by the presets: shell/shellcheck.
Suppress one line with sudsy-disable-next-line unquoted-pattern in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”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 [[ ]]. |