The return
statement in Bash doesn't return a value like C-functions, instead it exits the function with a return status. You can think of it as the exit status of that function.
If you want to return a value from the function then send the value to stdout
like this:
fun() {
local var="Sample value to be returned"
echo "$var"
#printf "%s\n" "$var"
}
Now, if you do:
var="$(fun)"
the output of fun
will be stored in $var
.