The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 09-29-2006
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
in a shell script:

function_name # call the function
return_val=$? # store the return value
echo $return_val # do something with the return value

Function can return a value, called an exit status

The exit status may be explicitly specified by a return statement, otherwise it is the exit status of the last command in the function

This exit status may be used in the script by referencing it as $?

The largest positive integer a function can return is 255