LINUX.ORG.RU

ничем, синтактический сахар

     A command substitution is replaced by the output generated by the speci-
     fied command, which is run in a subshell.  For $(command) substitutions,
     normal quoting rules are used when command is parsed; however, for the
     `command` form, a `\' followed by any of `$', ``', or `\' is stripped (a
     `\' followed by any other character is unchanged).  As a special case in
     command substitutions, a command of the form <file is interpreted to mean
     substitute the contents of file.  Note that $(< foo) has the same effect
     as $(cat foo), but it is carried out more efficiently because no process
     is started.

     Note: $(command) expressions are currently parsed by finding the matching
     parenthesis, regardless of quoting.  This should be fixed soon.
beastie ★★★★★
()

спасибо, понятно.

mono ★★★★★
() автор топика

Тоже давно мучал этот вопрос.

yaba ★★
()

Бэкслэши - олдстайл. Рекомендуется употреблять доллар-скобку.

Xenesz ★★★★
()

Кавычки - для обратной совместимости.

GotF ★★★★★
()

если вкратце: первое можно только на баше, на sh нельзя. Зато второе не поддерживает вложенность, в то время, как в первом можно $(pkg-config --cflags $(find gtk| sed somth))

name_no ★★
()
Ответ на: комментарий от Xenesz

4.2. Вложенность допускают обе формы.

man bash

To nest when using the backquoted form, escape the inner backquotes with backslashes

Убедил.

TEST=`echo \`which \\\`echo $SHELL\\\`\``
vs
TEST=$(echo $(which $(echo $SHELL)))

name_no ★★
()
Ответ на: комментарий от mrdeath

> $() это башизм

не, в текущем позиксе $() присутствует.

Как выше сказали, проще вложенные $() писать.

dilmah ★★★★★
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.