2023-07-05 10:53:12 +02:00
|
|
|
# The return builtin command
|
|
|
|
|
|
|
|
## Synopsis
|
|
|
|
|
|
|
|
return [N]
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
|
|
|
The `return` command returns from a shell function.
|
|
|
|
|
|
|
|
If `N` is given, the return code to the caller is set to `N`. If not,
|
|
|
|
the returned status the the status of the most recently executed command
|
|
|
|
(i.e. `$?`).
|
|
|
|
|
|
|
|
### Options
|
|
|
|
|
|
|
|
There are no options.
|
|
|
|
|
|
|
|
### Exit status
|
|
|
|
|
2024-03-30 20:09:26 +01:00
|
|
|
If everything is okay, the `return` command doesn't come back. If it
|
2023-07-05 10:53:12 +02:00
|
|
|
comes back, there was a problem in doing the return.
|
|
|
|
|
|
|
|
Status Reason
|
|
|
|
-------- -------------------------------------------------------------------------
|
|
|
|
1 `return` was called while not being in a shell function or sourced file
|
|
|
|
|
|
|
|
## Examples
|
|
|
|
|
|
|
|
## Portability considerations
|
|
|
|
|
|
|
|
## See also
|
|
|
|
|
2024-01-29 02:07:56 +01:00
|
|
|
- [The exit builtin command](../../commands/builtin/exit.md)
|
2024-04-02 23:19:23 +02:00
|
|
|
- [The exit status](../../dict/exit_status.md)
|