bashcommand-substitutionbrace-expansion

The interpretation between the braces in the brace expansion


In Bash Beginners Guide Book

Brace expansion is performed before any other expansions, and any characters special to other expansions are preserved in the result. It is strictly textual. Bash does not apply any syntactic interpretation to the context of the expansion or the text between the braces. To avoid conflicts with parameter expansion, the string "${" is not considered eligible for brace expansion.

In This paragraph it says that the Bash does not apply any syntactic interpretation to the context of the expansion or the text between the braces, but when I executed this command

h{elp,`uname`}

It returned

bash: help: no help topics match `hLinux'.  Try `help help' or `man -k hLinux' or `info hLinux'.

It retuend the word hLinux instead of h`uname`. So the `uname` is interpreted even when it was between the braces, why ?

Bash Beginners Guide Screenshot of the space paragraph


Solution

  • The brace expansion in your example did not return hLinux. It returned help h`uname`.

    Only in a second step, Bash applied command substitiution to `uname`, which made the entire command help hLinux.

    Brace expansion does not stop other mechanisms to be applied on the result afterwards. It just does not parse anything by itself.