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:

  1. 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.

  2. Alias Substitution: Recognizing when the first token (the command) as an alias and expanding it.

  3. Tilde Substitution: Replacing ~ with their expanded values.

  4. 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.

  5. Parameter Expansion: Shell variable expansion and shell expression expansion.

  6. Wildcard Expansion: Replacing shell metacharacters in pathnames with expanded values.

  7. Quote Processing: Removal of most quotes from the command line (except escaped quotes and quotes residing in variable values.

  8. I/O Redirection: Redirection of STDIN, STDOUT, STDERR and file descriptors.

  9. 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