Is command substitution $(foo) bashism?

浪子不回头ぞ 提交于 2019-11-28 23:39:32

It's the same thing. So no it's not a bashism nor related to bash only.

Command Substitution
Command substitution allows the output of a command to be substituted in place of the command name itself. Command substitution occurs when the command is enclosed as follows:

$(command)

or ( ''backquoted'' version):

`command`

The shell expands the command substitution by executing command in a subshell environment and replacing the command substitution with the standard output of the command, removing sequences of one or more newlines at the end of the substitution. (Embedded newlines before the end of the output are not removed; however, during field splitting, they may be translated into spaces, depending on the value of IFS and quoting that is in effect.)


Resources :

Chris Dodd

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.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!