In the following script, the effect of calling f0 is that the value global $i is still 5, but the effect of calling f1 is that the value of the global $i is 9. It's nice to be able to create a function like unlocal that moves local variables out of the way, but I'm wondering if it can be relied on in future
versions:

    unlocal () {
        unset -v "$@"
    }

    f0 () {
     local i
     i=3
     unset -v i
     f1
     i=9
    }

    f1 () {
        local i
        i=3
        unlocal i
        i=9
    }

    i=5


--
Yorick


Reply via email to