mirror of
https://codeberg.org/la-chouette/minishell.git
synced 2025-12-06 07:28:09 +01:00
notes: add exit status section
This commit is contained in:
parent
6672aec007
commit
b450220720
1 changed files with 32 additions and 1 deletions
33
NOTES.md
33
NOTES.md
|
|
@ -438,7 +438,7 @@ a non-zero status.
|
||||||
If there is a command name left after expansion, execution proceeds as described
|
If there is a command name left after expansion, execution proceeds as described
|
||||||
below. Otherwise, the command exits with a status of zero.
|
below. Otherwise, the command exits with a status of zero.
|
||||||
|
|
||||||
##### Command Search and Execution
|
#### Command Search and Execution
|
||||||
cf. 3.7.2 Command Search and Execution
|
cf. 3.7.2 Command Search and Execution
|
||||||
|
|
||||||
After a command has been split into words, if it results in a simple command and
|
After a command has been split into words, if it results in a simple command and
|
||||||
|
|
@ -499,6 +499,37 @@ executed command consists of the shell's initial environment, whose values may
|
||||||
be modified in the shell, less any pairs removed by the 'unset' builtin, plus
|
be modified in the shell, less any pairs removed by the 'unset' builtin, plus
|
||||||
any additions via the 'export' command.
|
any additions via the 'export' command.
|
||||||
|
|
||||||
|
#### Exit Status
|
||||||
|
cf. 3.7.5 Exit Status
|
||||||
|
|
||||||
|
The exit status of an executed command is the value returned by the 'waitpid'
|
||||||
|
system call or equivalent function. Exit statuses fall between 0 and 255,
|
||||||
|
though, as explained below, the shell may use values above 125 specially. Exit
|
||||||
|
statuses from shell builtins and compound commands are also limited to this
|
||||||
|
range. Under certain circumstances, the shell will use special values to
|
||||||
|
indicate specific failure modes.
|
||||||
|
|
||||||
|
For the shell's purposes, a command which exits with a zero exit status has
|
||||||
|
succeeded. A non-zero exit status indicates failure. This seemingly
|
||||||
|
counter-intuitive scheme is used so there is one well-defined way to indicate
|
||||||
|
success and a variety of ways to indicate various failure modes. When a command
|
||||||
|
terminates on a fatal signal whose number is N, Bash uses the value 128+N as the
|
||||||
|
exit status.
|
||||||
|
|
||||||
|
If a command is not found, the child process created to execute it returns a
|
||||||
|
status of 127. If a command is found but is not executable, the return status
|
||||||
|
is 126.
|
||||||
|
|
||||||
|
If a command fails because of an error during expansion or redirection, the exit
|
||||||
|
status is greater than zero.
|
||||||
|
|
||||||
|
All of the Bash builtins return an exit status of zero if they succeed and a
|
||||||
|
non-zero status on failure, so they may be used by the conditional and list
|
||||||
|
constructs. All builtins return an exit status of 2 to indicate incorrect
|
||||||
|
usage, generally invalid options or missing arguments.
|
||||||
|
|
||||||
|
The exit status of the last command is available in the special parameter $?.
|
||||||
|
|
||||||
## Definitions
|
## Definitions
|
||||||
cf. [Bash Reference Manual](https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Definitions)
|
cf. [Bash Reference Manual](https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html#Definitions)
|
||||||
cf. 2 Definitions
|
cf. 2 Definitions
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue