-
Notifications
You must be signed in to change notification settings - Fork 1.8k
SC2006
Grzegorz Szymaszek edited this page Nov 3, 2024
·
19 revisions
echo "You are running on `uname`"
echo "You are running on $(uname)"
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.
- Some legacy sh implementations (like Solaris) do not support
$(...)
, it is necessary to use backtick command substitution there. See [mc-devel] [PATCH] Prefer $() to backticks in sh script and follow-ups.
- BashFaq: Why is
$(...)
preferred over`...`
(backticks)? - StackOverflow: What is the difference between $(command) and
`command`
in shell programming? - shfmt will automatically convert the legacy syntax