There are two different syntaxes for command substitution,
FOO=$(echo bar)
and
FOO=`echo bar`
As far as I know, the first method is defined in Bash, while the second is defined in sh
.
Consider the following use of command substitution in an sh
script.
#!/bin/sh
FOO=$(echo bar)
Does that fall under the definition of bashism?
bashisms, i.e. features not defined by POSIX (won't work in dash, or general /bin/sh).
Actually, the $(
...)
command substitution syntax is defined by POSIX, though it's not part of the earlier SVID sh
standard. So as long as you don't care about running on pre-POSIX systems, it should be fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With