全局变量

var="hello"

function foo(){
    echo $var
}

foo

显然会输出你好,但这也是另一种方式:

function foo()  {
    var="hello"
}

foo
echo $var

还会输出 hello