From 5434bc900ac6ae024520c33e45623c072e34ff82 Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 8 Feb 2014 10:42:49 -0800 Subject: [PATCH] Created SC2006 (markdown) --- SC2006.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 SC2006.md diff --git a/SC2006.md b/SC2006.md new file mode 100644 index 0000000..c7245ed --- /dev/null +++ b/SC2006.md @@ -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. \ No newline at end of file