Skip to content

quote-command-substitution

Shellsuspiciousno fixdefault: warnshell/shellcheck

Reports an unquoted $(...) or backtick substitution in the arguments of a command.

The output is split on blanks and globbed, so a result with spaces becomes several arguments, an empty one disappears, and a * becomes file names.

To fix, quote it: "$(cmd)".

Reported
...
cat -n in.txt | grep x
cat a b | grep x
grep x in.txt
echo $(date)
...
echo `date`
echo "$(date) now" $x
echo "$(date)s"
...
shell:
lint:
rules:
quote-command-substitution: warn # off, warn (default), error

Enabled by the presets: shell/shellcheck.

Suppress one line with sudsy-disable-next-line quote-command-substitution in a comment of the file’s language.

The same check in other tools; Sudsy reports what each upstream rule reports.

Tool Rule Match
shellcheck SC2046 full