Skip to content

Files

Latest commit

 

History

History
30 lines (19 loc) · 767 Bytes

SC2006.md

File metadata and controls

30 lines (19 loc) · 767 Bytes

Pattern: Use of legacy `STATEMENT`

Issue: -

Description

Backtick command substitution `STATEMENT` 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.

$(STATEMENT) command substitution has none of these problems, and is therefore strongly encouraged.

Example of incorrect code:

echo "Current time: `date`"

Example of correct code:

echo "Current time: $(date)"

Further Reading