O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

19.4. Returning from a called function

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:

  1. 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.

  2. 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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required