Command
Processing
***Do not print the entire document as the document
contains many blank pages. Only the first 2 pages should be printed.***
There are 9 basic step taken by the bash & Korn
Shells1 in processing a command
line to execution, beginning right after the keystroke is read:
- Token Splitting:
Dividing the input character stream into symbols and recognizing all
Input/Output redirection operators. In loose terms, a token is typically a
stream of characters separated by two of: whitespace, start of line, newline
or carriage return, pipe, redirection operator, quote, parenthesis. The
command option[s] are part of the command token.
- Alias Substitution:
Recognizing when the first token (the command) as an alias and expanding
it.
- Tilde Substitution:
Replacing
~
with their expanded
values.
- Command Substitution:
Evaluating commands inside expanded parenthesis,
$(...)
or backquotes,
`...`
. In this case, the nested
command is evaluated beginning with step 1. Their resultant STDOUT replaces
the nested command.
- Parameter Expansion:
Shell variable expansion and shell expression expansion.
- Wildcard Expansion:
Replacing shell metacharacters in pathnames with expanded
values.
- Quote Processing:
Removal of most quotes from the command line (except escaped quotes and quotes
residing in variable values.
- I/O Redirection:
Redirection of STDIN, STDOUT, STDERR and file descriptors.
- Execution: Command is
executed.
Which of the steps apply to this sample command string:
mail -s "$host System Maintenance Warning!" `cat ~/userlist*`
< maint010603.doc
Answer at
bottom of document.
1. The Bourne Shell
is without some features of bash and Korn such as aliases and tilde expansion
and therefor omits some steps.
Answer to above: 1, 4( 1, 3, 6, 9) 5, 7, 8, 9
Back to top