bash: Exit Status

1 
1 3.7.5 Exit Status
1 -----------------
1 
1 The exit status of an executed command is the value returned by the
1 WAITPID system call or equivalent function.  Exit statuses fall between
1 0 and 255, though, as explained below, the shell may use values above
1 125 specially.  Exit statuses from shell builtins and compound commands
1 are also limited to this range.  Under certain circumstances, the shell
1 will use special values to indicate specific failure modes.
1 
1    For the shell's purposes, a command which exits with a zero exit
1 status has succeeded.  A non-zero exit status indicates failure.  This
1 seemingly counter-intuitive scheme is used so there is one well-defined
1 way to indicate success and a variety of ways to indicate various
1 failure modes.  When a command terminates on a fatal signal whose number
1 is N, Bash uses the value 128+N as the exit status.
1 
1    If a command is not found, the child process created to execute it
1 returns a status of 127.  If a command is found but is not executable,
1 the return status is 126.
1 
1    If a command fails because of an error during expansion or
1 redirection, the exit status is greater than zero.
1 
11 Conditional Constructs::) and some of the list constructs (⇒
 Lists).
1 
1    All of the Bash builtins return an exit status of zero if they
1 succeed and a non-zero status on failure, so they may be used by the
1 conditional and list constructs.  All builtins return an exit status of
1 2 to indicate incorrect usage, generally invalid options or missing
1 arguments.
1