0

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

Community
  • 1
  • 1
Bahamas
  • 5
  • 2

1 Answers1

1

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.

Johannes H.
  • 5,875
  • 1
  • 20
  • 40
  • 1
    Additionally from the documentation (`man bash`): *The order of expansions is: brace expansion; tilde expansion, parameter and variable expansion, arithmetic expansion, and command substitution (done in a left-to-right fashion); word splitting; and pathname expansion.* – Cyrus May 03 '20 at 09:15
  • Sidenote: If you DO want to stop any parsing of a string in bash, that's what single quotes are fore. – Johannes H. May 03 '20 at 09:16