MPE/iX Shell and Utilities Reference Manual, Vol 2

sh(1) MPE/iX Shell and Utilities sh(1)
Word Expansion
sh performs word expansion for simple commands, some reserved word commands, redirec-
tion file names, some shell variables (
ENV
,
MAILPATH
,
PS1
, and
PS4
), and unquoted here
documents. There are four steps to expansion: substitution, word splitting, path expansion,
and quote removal.
Directory substitution, parameter substitution, command substitution, and arithmetic substitu-
tion are each described in the appropriate section of this man page.
Word splitting checks each unquoted character from the previous step. If the character is one
of those indicated by the
IFS
variable (by default, space, tab, and newline), sh splits the
word into multiple words. When
IFS
contains an empty string, word expansion is not per-
formed.
If a word contains an unquoted *, ?,or], that word is subject to path name expansion (see
Path Name Expansion). Path name expansion is disabled if the –f or –o noglob shell flag
is set (see set(1)).
Finally, sh removes any quote characters (\, , and ") from the original word. In here docu-
ments (see the description of number<<[-]name in the section File Descriptors and Redirec-
tion) and shell variables that expand, single and double quotes have no special meaning and
are not removed.
sh may or may not do all of these steps, depending on where word expansion is performed.
Table 1-10, Word Expansion summarizes what steps are done. The Arguments entry refers
to the word list of for and select commands as well as simple commands.
Directory Other Word Path
Substitution Substitution Splitting Expansion
Arguments yes yes yes yes
Assignments yes yes no no
Redirection yes yes no yes/no*
Here documents no yes no no
Case statement yes yes no no
Shell variables no yes no no
* yes for interactive shell, no otherwise
Table 1-10: Word Expansion
Commands and Utilities 1-527