return

Official Description

Causes a shell function to return to the invoking script with the return status specified by n.

Syntax

return [n]

Options

None

Oddities

If return is invoked while not in a function or a . (dot) script, it is the same as an exit.

Example

$ function ob_1 {            # Create function that returns 32
> print "Can ob?"
> return 32                   # Returns arbitrary number (32)
> }
$
$ ob_1                        # Execute function
Can ob?
$ print $?                    # Display return status
32
$
				

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.