function double {
read -p "Enter the value: " value
return $(($value * 2))
}
result=$(double)
echo "The new result is $result."
When I run this piece of code the echo
command doesn't print the computed value, but when I changed result=$(double)
to double; result=$?
it worked. Why can't I just assign the return value directly?