RosettaCodeData/Task/Function-definition/UNIX-Shell/function-definition-1.sh

11 lines
464 B
Bash
Raw Permalink Normal View History

2013-04-10 22:43:41 -07:00
multiply() {
# There is never anything between the parentheses after the function name
# Arguments are obtained using the positional parameters $1, and $2
# The return is given as a parameter to the return command
return `expr "$1" \* "$2"` # The backslash is required to suppress interpolation
}
# Call the function
multiply 3 4 # The function is invoked in statement context
2014-01-17 05:32:22 +00:00
echo $? # The dollarhook special variable gives the return value