3.5 Error Handling: Execution of A Command (See Also 3.7) May Fail For Any of The Following Reasons
3.5 Error Handling: Execution of A Command (See Also 3.7) May Fail For Any of The Following Reasons
is equivalent to
who|grep fred
In this example, eval is required since there is no interpretation of metacharacters, such as |, following substitution.
Execution of a command (see also 3.7) may fail for any of the following reasons.
Input - output redirection may fail. For example, if a file does not exist or cannot be created. The command itself does not exist or cannot be executed. The command terminates abnormally, for example, with a "bus error" or "memory fault". See Figure 2 below for a complete list of UNIX signals. The command terminates normally but returns a non-zero exit status.
In all of these cases the shell will go on to execute the next command. Except for the last case an error message will be printed by the shell. All remaining errors cause the shell to exit from a command procedure. An interactive shell will return to read another command from the terminal. Such errors include the following.
Syntax errors. e.g., if ... then ... done A signal such as interrupt. The shell waits for the current command, if any, to finish execution and then either exits or returns to the terminal. Failure of any of the built-in commands such as cd.
The shell flag -e causes the shell to terminate if any error is detected. 1 hangup 2 interrupt 3* quit 4*
illegal instruction 5* trace trap 6* IOT instruction 7* EMT instruction 8* floating point exception 9 kill (cannot be caught or ignored) 10* bus error 11*