How to return a value from a bash function in a bash script
Even though bash doesn't technically allow you to return a value (even through it has a return statement), there are ways you can accomplish this in the Return a value in a bash script says how, but I like tamasgal's answer best:
function fun1(){
echo 34
}
function fun2(){
local …