-1

I came across the term "word expansion" here:

leave all the other word expansions ($non_exported_shell_variable, $1, $#, ${HOME+x}, $((1 + 1)), $(cmd)...) untouched

I would say that I know what is to expand a variable as with ${HOME} but what is a "word expansion"?

Perhaps it is an alternative term for "word splitting" (which is by itself an alternative term for "field splitting").

Update

Due to the linked answer's longevity and cognitive biases while first reading it (mostly or only because of lack of knowledge about many concepts mentioned in it then) I didn't internalize a note in it which reads:

Word expansion in this context refers to parameter expansion, arithmetic expansion and command substitution. That doesn't include filename generation (aka globbing or pathname expansion), tilde expansion nor brace expansion (itself not a standard sh feature). Using a here-document here makes sure ' and "s are left untouched, but note that there still is backslash processing.

  • Have you asked in a comment? – choroba Mar 18 '21 at 11:45
  • No and I can't but: – variable_expander Mar 18 '21 at 11:47
  • due to the answer's longevity and cognitive biases while first reading it (mostly because of lack of knowledge about many concepts mentioned in it) I didn't internalize the note about it: Word expansion in this context refers to parameter expansion, arithmetic expansion and command substitution. That doesn't include filename generation (aka globbing or pathname expansion), tilde expansion nor brace expansion (itself not a standard sh feature). Using a here-document here makes sure ' and "s are left untouched, but note that there still is backslash processing. – variable_expander Mar 18 '21 at 11:48
  • This question can either be deleted or answered if this is a formal term ; anyway, I can only hope Stéphane Chazelas would edit his answer or split it to different existing questions (and there are many on this topic of IFS) to ensure modularity and accessibility of some data parts in it. – variable_expander Mar 18 '21 at 11:52

1 Answers1

1

“Word expansions” (note the plural) are defined in detail in POSIX; they are

  • tilde expansion (~)
  • parameter expansion (${})
  • command substitution ($())
  • arithmetic expansion ($(()))
  • pathname expansion

“Word expansion” is the application of all the above, in conjunction with a couple of other shell parsing features, in a specific order:

  1. tilde expansion, parameter expansion, command substitution, arithmetic expansion
  2. field splitting
  3. pathname expansion
  4. quote removal

See the POSIX specification linked above, it specifies all this in exhaustive detail.

Stephen Kitt
  • 434,908