Bash (specifically Bash, not POSIX sh) does have a keyword for functions (function), but it’s optional.
- 0 Posts
- 3 Comments
Joined 1 year ago
Cake day: October 1st, 2024
You are not logged in. If you use a Fediverse account that is able to follow users, you can follow this user.
excess0680@lemmy.worldto
Linux@programming.dev•Which command substitution do you prefer in shell scripts: backquotes `` or $() syntax?
3·13 days agoBy some sheer coincidence, I searched this topic today. I’ve been a consistent user of the parenthesis expansion, but never thought of why I preferred one or the other.
I suppose the primary advantage is that $() will expand in a consistent way. You can even nest quotes and more expansions in one, while you’d struggle the same with backtick notation.
So I’ll just keep using parentheses.

Right. It’s optional so that Bash remains backwards compatible as a superset of POSIX sh. If you’re working with exclusively Bash, though, it’s nice to use as syntactic sugar if nothing else.