Created SC2006 (markdown)

koalaman
2014-02-08 10:42:49 -08:00
parent d4a2fb32c8
commit 5434bc900a

23
SC2006.md Normal file

@@ -0,0 +1,23 @@
# Use $(..) instead of deprecated `..`
### Problematic code:
echo "Current time: `date`"
### Correct code:
echo "Current time: $(date)"
### Rationale:
Backtick command substitution `` `..` `` is legacy syntax with several problems.
1. It has a series of undefined behaviors related to quoting in POSIX.
1. It imposes a custom escaping mode with surprising results.
1. It's exceptionally hard to nest.
`$(..)` command substitution has none of these problems, and is therefore strongly encouraged.
### Contraindications
None.