| 1 |
# General Command Line Topics |
| 2 |
|
| 3 |
```{currentmodule} click |
| 4 |
``` |
| 5 |
|
| 6 |
```{contents} |
| 7 |
--- |
| 8 |
depth: 1 |
| 9 |
local: true |
| 10 |
--- |
| 11 |
``` |
| 12 |
|
| 13 |
(exit-codes)= |
| 14 |
## Exit Codes |
| 15 |
|
| 16 |
When a command is executed from the command line, then an exit code is return. The exit code, also called exit status or exit status code, is a positive integer that tells you whether the command executed with or without errors. |
| 17 |
|
| 18 |
| Exit Code | Meaning | |
| 19 |
|-----------|-------------------------------------------------| |
| 20 |
| 0 | Success — the command completed without errors. | |
| 21 |
| > 0 | Executed with errors | |
| 22 |
|
| 23 |
Exit codes greater than zero mean are specific to the Operating System, Shell, and/or command. |
| 24 |
|
| 25 |
To access the exit code, execute the command, then do the following depending: |
| 26 |
|
| 27 |
```{eval-rst} |
| 28 |
.. tabs:: |
| 29 |
|
| 30 |
.. group-tab:: Powershell |
| 31 |
|
| 32 |
.. code-block:: powershell |
| 33 |
|
| 34 |
> echo $LASTEXITCODE |
| 35 |
|
| 36 |
.. group-tab:: Bash |
| 37 |
|
| 38 |
.. code-block:: bash |
| 39 |
|
| 40 |
$ echo $? |
| 41 |
|
| 42 |
.. group-tab:: Command Prompt |
| 43 |
|
| 44 |
|
| 45 |
.. code-block:: text |
| 46 |
|
| 47 |
> echo %ERRORLEVEL% |
| 48 |
``` |
| 49 |
|
| 50 |
For Click specific behavior on exit codes, see {ref}`exception-handling-exit-codes`. |