[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "unset var" pops var off variable stack instead of unsetting it
From: |
Stephane Chazelas |
Subject: |
Re: "unset var" pops var off variable stack instead of unsetting it |
Date: |
Tue, 21 Mar 2017 15:38:55 +0000 |
User-agent: |
Mutt/1.5.24 (2015-08-30) |
2017-03-20 16:32:10 -0400, Chet Ramey:
[...]
> > See also:
> >
> > $ bash -c 'f() { unset a; echo "$a";}; a=1; a=2 f'
> > 1
> >
> > already mentioned.
>
> A distinction without a difference; the behavior is explicitly the same.
[...]
One I haven't mentioned yet is:
$ bash -c 'f() { local a; unset a; echo "$a";}; a=1; a=2 f'
1
IOW, the work around I was mentioning earlier (of using "local"
before "unset" to make sure "unset" unsets) doesn't work in that
case. You'd need to use the same work around as for mksh/yash
(call unset in a loop until the variable is really unset (with
the nasty side effect of unsetting the variable in a scope
you're need meant to tamper with) so you'd want to do it in a
subshell).
--
Stephane
- Re: "unset var" pops var off variable stack instead of unsetting it, (continued)
- Re: "unset var" pops var off variable stack instead of unsetting it, Grisha Levit, 2017/03/17
- Re: "unset var" pops var off variable stack instead of unsetting it, Dan Douglas, 2017/03/17
- Re: "unset var" pops var off variable stack instead of unsetting it, Stephane Chazelas, 2017/03/17
- Re: "unset var" pops var off variable stack instead of unsetting it, Chet Ramey, 2017/03/18
- Re: "unset var" pops var off variable stack instead of unsetting it, Eric Blake, 2017/03/20
- Re: "unset var" pops var off variable stack instead of unsetting it, Chet Ramey, 2017/03/20
- Re: "unset var" pops var off variable stack instead of unsetting it, Stephane Chazelas, 2017/03/20
- Re: "unset var" pops var off variable stack instead of unsetting it, Chet Ramey, 2017/03/20
- Re: "unset var" pops var off variable stack instead of unsetting it,
Stephane Chazelas <=
- Re: "unset var" pops var off variable stack instead of unsetting it, Martijn Dekker, 2017/03/22
Re: "unset var" pops var off variable stack instead of unsetting it, Chet Ramey, 2017/03/18
Re: "unset var" pops var off variable stack instead of unsetting it, Chet Ramey, 2017/03/18