function my_function {
echo "Return value."
}
result=$(my_function)
return statement
Beware! Do not use the return
statement to return a value. The return
statement is used to return exit codes, usually 0 for a normal exit, and 1 if an error occurred within the function. Instead, use the format above.
From help return:
return: return [n]
Return from a shell function.
Causes a function or sourced script to exit with the return value
specified by N. If N is omitted, the return status is that of the