bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG] 'unset' fails silently under specific conditions


From: Greg Wooledge
Subject: Re: [BUG] 'unset' fails silently under specific conditions
Date: Wed, 2 May 2018 10:38:29 -0400
User-agent: NeoMutt/20170113 (1.7.2)

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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]