On Wed, May 02, 2018 at 10:32:52AM -0400, Greg Wooledge wrote: > wooledg:~$ bash > wooledg:~$ set -o posix > wooledg:~$ f() { foo=bar; foo=baz : ; }; f > wooledg:~$ declare -p foo > declare -x foo="baz" > > What did you see that led you to conclude there is a local variable > involved? (Not counting discussions with Chet!)
After sending that, I saw the Subject: header, and figured maybe you left something out in your example. Trying again, this time with an unset command in the mix: wooledg:~$ bash wooledg:~$ set -o posix wooledg:~$ f() { foo=bar; declare -p foo; foo=baz :; declare -p foo; unset foo; declare -p foo; }; f declare -- foo="bar" declare -x foo="baz" declare -- foo="bar" wooledg:~$ declare -p foo declare -- foo="bar" wooledg:~$ env | grep foo= wooledg:~$ *NOW* there's evidence of a local variable, because unset removes it and exposes the global. But it's not "permanently exported" as far as I can see.