Updated SC2006 (markdown)

Vidar Holen
2018-07-26 19:59:29 -07:00
parent 6875635736
commit c77f360d16

@@ -1,4 +1,4 @@
# Use $(STATEMENT) instead of legacy \`STATEMENT\` # Use `$(...)` notation instead of legacy backticked `` `...` ``.
### Problematic code ### Problematic code
@@ -14,13 +14,13 @@ echo "Current time: $(date)"
### Rationale ### Rationale
Backtick command substitution `` `STATEMENT` `` is legacy syntax with several issues. Backtick command substitution `` `...` `` is legacy syntax with several issues.
1. It has a series of undefined behaviors related to quoting in POSIX. 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 imposes a custom escaping mode with surprising results.
1. It's exceptionally hard to nest. 1. It's exceptionally hard to nest.
`$(STATEMENT)` command substitution has none of these problems, and is therefore strongly encouraged. `$(...)` command substitution has none of these problems, and is therefore strongly encouraged.
### Exceptions ### Exceptions
@@ -28,5 +28,5 @@ None.
### Related resources: ### Related resources:
* [BashFaq: Why is $(...) preferred over `` `...` `` (backticks)?](http://mywiki.wooledge.org/BashFAQ/082) * [BashFaq: Why is `$(...)` preferred over `` `...` `` (backticks)?](http://mywiki.wooledge.org/BashFAQ/082)
* [StackOverflow: What is the difference between $(command) and `` `command` `` in shell programming?](https://stackoverflow.com/questions/4708549/shell-programming-whats-the-difference-between-command-and-command) * [StackOverflow: What is the difference between $(command) and `` `command` `` in shell programming?](https://stackoverflow.com/questions/4708549/shell-programming-whats-the-difference-between-command-and-command)