echo-in-substitution
What it does
Section titled “What it does”Reports a command substitution that only runs echo on words, as in $(echo $a $b).
Why it matters
Section titled “Why it matters”It runs a subshell to print what the shell already has. Unquoted, it also splits and globs the words and, with some shells, interprets backslashes.
To fix, use the words directly, and quote them.
Example
Section titled “Example”...unset "words[0]"...[[ $a == "$b" ]]x=$(echo $y)x=$(echo "a" | tr a b)...Configuration
Section titled “Configuration”shell: lint: rules: echo-in-substitution: warn # off (default), warn, errorEnabled by the presets: shell/shellcheck.
Suppress one line with sudsy-disable-next-line echo-in-substitution 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 | SC2116 |
partial | Only $(echo words) with plain words. |