quote-array-element
What it does
Section titled “What it does”Reports an unquoted $var or ${var} among the elements of an array assignment, as in arr=($x y).
Why it matters
Section titled “Why it matters”The expansion is split into words and globbed, so one element becomes several, or none, and a * becomes file names. The shell does not know which variables hold a single word.
To fix, quote it: arr=("$x" y).
Example
Section titled “Example”...l+=($dl)x=($dl "q" "$m")...echo "$@" "${s[@]}"...Configuration
Section titled “Configuration”shell: lint: rules: quote-array-element: warn # off (default), warn, errorEnabled by the presets: shell/shellcheck.
Suppress one line with sudsy-disable-next-line quote-array-element 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 | SC2206 |
partial | $var and ${var} among the elements, not other expansions. |