When a function has finished processing or you wish the function to finish based on a conditional statement, you can do one of two things:
Let the function fall through naturally to the end of the function, thus returning control back to the part of the script that called it.
Use the word ‘return’, which will return from the function to the next statement of your script from whence it was called. A value can be used with the return; this is optional, and is 0 for non-errors and 1 for errors, pretty much the same as the last status command reports. The format is:
|return||will return from the function, use the last status command to determine status|
|return 0||for non-errors|
|return 1||for errors|