The return command is used to return from a procedure. It is needed if return is to occur before the end of the procedure body, or if a constant value needs to be returned. As a matter of style, I also use return at the end of a procedure, even though a procedure returns the value of the last command executed in the body.
Exceptional return conditions can be specified with some optional arguments to return. The complete syntax is:
return ?-code c? ?-errorinfo i? ?-errorcode ec? string
The -code option value is one of ok, error, return, break, continue, or an integer. ok is the default if -code is not specified.
The -code error option makes return behave much like the error command. The -errorcode option sets the global errorCode variable, ...