var1="global var" test() { local var2="local var" echo $var2 } echo $var1 test echo $var2 test2() { echo $var2 }