Reputation: 19
example (){
......
local var
......
return $var
}
user_val=$(example $number1 $number2)
I need user_val and i will it. I got error. Code can't detect the function when I try it this way.
Upvotes: 0
Views: 53
Reputation: 198
@Barmar is correct. Replace return
with echo
in your function. Using var=$(...)
assigns the output of the function to the variable.
When using return
the value is saved in $?
.
Upvotes: 2