function::returnval - Linux


function::returnval is a command used in Shell script programming to access the return value of a previously executed function. It allows you to capture and manipulate the exit status of a function and use it for further processing or decision-making within the script.



There are no parameters or options for this command.


This command has no options or flags.


Example 1: Capturing the return value of a function

my_function() {
    return 0  # Success

result=$(function::returnval my_function)

if [ $result -eq 0 ]; then
    echo "Function executed successfully."

Example 2: Using the return value in a conditional statement

if function::returnval my_other_function; then
    # Do something if the function returned 0 (success)
    # Do something if the function returned non-zero (failure)

Common Issues

  • Incorrectly placed command: The command should be placed immediately after the function call, or it may capture the return value of a subsequent command.
  • Mismatched parentheses: If parentheses are used around the function call, ensure they are closed properly, or the command may not work.


  • With conditionals: Use function::returnval to control conditional execution flows based on the success or failure of a function.
  • With scripts: Combine with other Linux commands to automate tasks or create complex scripts that rely on function return values.

Related Commands

  • functions: Declare and manage shell functions.
  • return: Exit a function with a specific return code.
  • test: Evaluate conditions and perform actions based on their truthiness.