Back to Fish

return - stop the current inner function¶

site/docs/3.4/cmds/return.html

latest1.1 KB
Original Source

return - stop the current inner function

Synopsis

return [N]

Description

return halts a currently running function. The exit status is set to N if it is given. If return is invoked outside of a function or dot script it is equivalent to exit.

It is often added inside of a conditional block such as an if statement or a switch statement to conditionally stop the executing function and return to the caller; it can also be used to specify the exit status of a function.

If at the top level of a script, it exits with the given status, like exit. If at the top level in an interactive session, it will set status, but not exit the shell.

The -h or --help option displays help about using this command.

Example

An implementation of the false command as a fish function:

function falsereturn 1end