Configuring and working with the shells

How the shell works

Your login shell reads its standard input from your terminal, and sends its standard output and standard error back to your terminal unless you tell it to send them elsewhere. (See ``More about redirecting input and output'' for more information on these streams.) The shell is line oriented; it does not process your commands until you press <Enter> to indicate the end of a line. You can correct your typing as you go. Different shells provide different facilities for editing your commands, but they generally recognize <Bksp> or <Del> as the keystroke to delete the previous character.

When you press <Enter>, the shell interprets the line you have entered before it executes the commands on that line. The steps it runs through are as follows:

  1. The shell splits the line into tokens. A token is a command, variable, or other symbol recognized by the shell. It continues to build up a sequence of tokens until it comes to a reserved word (a shell internal command that governs the flow of control of a shell script), function name, or operator (a symbol denoting a pipe, a logical condition, a command separator, or some other operation that cannot be carried out until the preceding command is evaluated).

  2. The shell organizes the tokens into three categories:

  3. The commands may then be executed, either as internal shell commands (that cause the shell itself to take some action) or, if they are not internal commands, as external programs (if the shell can locate an executable file of that name).

Next topic: How the shell executes commands
Previous topic: How aliases are executed

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003