Terminologia para o comando no comando $ (…)

0

Eu tenho um script update-wallpaper que é um pouco assim:

ln -s $(get-wallpaper-path) ~/.config/bg-manager/wallpaper

A experssion $( ... ) é chamada ... alguma coisa ... e a pesquisa dos símbolos $() no Google e no Bing não resulta em resultados.

Enquanto a frase "Comando Inline" parece boa, não parece que é o termo oficial - pelo menos com o meu mecanismo de busca favorito. Qual seria a frase "oficial"?

    
por Lawful Lazy 17.11.2016 / 02:53

1 resposta

4

Você pode obter essas informações em sua máquina local pesquisando $( na página man do Bash:

tomas@tomas-Latitude-E4200:~$ man bash | grep -A2 -B2 '$('
       If value is not given, the variable is assigned the null string.  All values undergo tilde expansion, parameter and variable expansion, command sub‐
       stitution, arithmetic expansion, and quote removal (see EXPANSION below).  If the variable has its integer attribute set, then value is evaluated as
       an  arithmetic  expression  even  if the $((...)) expansion is not used (see Arithmetic Expansion below).  Word splitting is not performed, with the
       exception of "$@" as explained below under Special Parameters.  Pathname expansion is not performed.  Assignment statements may also appear as argu‐
       ments  to  the  alias,  declare,  typeset, export, readonly, and local builtin commands.  When in posix mode, these builtins may appear in a command
--
       Command substitution allows the output of a command to replace the command name.  There are two forms:

              $(command)
       or
              'command'

       Bash  performs  the expansion by executing command and replacing the command substitution with the standard output of the command, with any trailing
       newlines deleted.  Embedded newlines are not deleted, but they may be removed during word splitting.  The command substitution $(cat  file)  can  be
       replaced by the equivalent but faster $(< file).

       When  the  old-style  backquote  form  of substitution is used, backslash retains its literal meaning except when followed by $, ', or \.  The first
       backquote not preceded by a backslash terminates the command substitution.  When using the $(command) form, all characters between  the  parentheses
       make up the command; none are treated specially.

--
       Arithmetic expansion allows the evaluation of an arithmetic expression and the substitution of the result.  The format for arithmetic expansion is:

              $((expression))

       The old format $[expression] is deprecated and will be removed in upcoming versions of bash.

Pode ser necessário algum ajuste para os parâmetros -A e -B . Eles definem o contexto anterior e posterior e dependem da própria página man , do conteúdo e da exibição do terminal - quantos caracteres são exibidos por linha. Então você precisa ver o que vê e pensar no que quer ver.

Mas o resultado pode ser gratificante. Este é o trecho-chave da primeira listagem:

       Command substitution allows the output of a command to replace the command name.  There are two forms:

              $(command)
       or
              'command'
    
por 17.11.2016 / 05:39