useless-echo
What it does
Section titled “What it does”Reports an echo whose only argument is a command substitution, as in echo $(cmd).
Why it matters
Section titled “Why it matters”The command already writes its output, so the echo adds a process and, unquoted, joins the lines with spaces and splits and globs the output.
To fix, run the command itself.
Example
Section titled “Example”...cat -n in.txt | grep xcat a b | grep xgrep x in.txtecho $(date)echo "$(date)"echo `date`echo "$(date) now" $xecho "$(date)s"...Configuration
Section titled “Configuration”shell: lint: rules: useless-echo: warn # off (default), warn, errorEnabled by the presets: shell/shellcheck.
Suppress one line with sudsy-disable-next-line useless-echo in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| shellcheck | SC2005 |
full |