將兩者混合在一起
var="hello"
function foo(){
local var="sup?"
echo "inside function, var=$var"
}
foo
echo "outside function, var=$var"
會輸出
inside function, var=sup?
outside function, var=hello
var="hello"
function foo(){
local var="sup?"
echo "inside function, var=$var"
}
foo
echo "outside function, var=$var"
會輸出
inside function, var=sup?
outside function, var=hello