koalaman / shellcheck Public
SC2006
Vidar Holen edited this page Apr 27, 2019
·
11 revisions
Use $(...) notation instead of legacy backticked `...`.
Problematic code
echo "You are running on `uname`"Correct code
echo "You are running on $(uname)"Rationale
Backtick command substitution `...` is legacy syntax with several issues.
- It has a series of undefined behaviors related to quoting in POSIX.
- It imposes a custom escaping mode with surprising results.
- It's exceptionally hard to nest.
$(...) command substitution has none of these problems, and is therefore strongly encouraged.
Exceptions
None.