SC2006 – ShellCheck Wiki

See this page on GitHub

Sitemap


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.

  1. It has a series of undefined behaviors related to quoting in POSIX.

  2. It imposes a custom escaping mode with surprising results.

  3. It's exceptionally hard to nest. $(...) command substitution has none of these problems, and is therefore strongly encouraged.

    Exceptions

    None.


ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.