[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Passing variables by reference conflicts with local
From: |
Freddy Vulto |
Subject: |
Re: Passing variables by reference conflicts with local |
Date: |
Tue, 4 May 2010 19:57:09 +0200 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
It appears that `unset' is capable of traversing down the call-stack and
unsetting variables repeatedly:
a=0 b=0 c=0 d=0 e=0
_unset() { unset -v b c c d d d e; }
t1() {
local a=1 b=1 c=1 d=1
t2
}
t2() {
local a=2 b=2 c=2 d=2 e=2
_unset
echo a:$a b:$b c:$c d:$d e:$e
}
t1 # Outputs: a:2 b:1 c:0 d: e:0
# ^ ^ ^ ^ ^-- unset once (skipped t1)
# | | | +----- unset thrice to global
# | | +--------- unset twice till global
# | +------------- unset once till t1
# +----------------- unset not
It seems to work on bash-3.0, 3.2, 4.0 and 4.1.
Is this a bug or a feature?
Freddy Vulto
http://fvue.nl/wiki/Bash:_passing_variables_by_reference
- Re: Passing variables by reference conflicts with local, Freddy Vulto, 2010/05/01
- Re: Passing variables by reference conflicts with local, Dennis Williamson, 2010/05/01
- Re: Passing variables by reference conflicts with local, Pierre Gaston, 2010/05/01
- Re: Passing variables by reference conflicts with local, Freddy Vulto, 2010/05/01
- Re: Passing variables by reference conflicts with local, Dennis Williamson, 2010/05/01
- Re: Passing variables by reference conflicts with local, Freddy Vulto, 2010/05/01
- Re: Passing variables by reference conflicts with local, Dennis Williamson, 2010/05/01
- Re: Passing variables by reference conflicts with local, Freddy Vulto, 2010/05/02
- Re: Passing variables by reference conflicts with local, Dennis Williamson, 2010/05/02
- Re: Passing variables by reference conflicts with local, Freddy Vulto, 2010/05/03
- Re: Passing variables by reference conflicts with local,
Freddy Vulto <=
- Re: Passing variables by reference conflicts with local, Chet Ramey, 2010/05/05
- Re: Passing variables by reference conflicts with local, Chet Ramey, 2010/05/04
- Re: Passing variables by reference conflicts with local, Chet Ramey, 2010/05/02
- Re: Passing variables by reference conflicts with local, Matthew Woehlke, 2010/05/03
Re: Passing variables by reference conflicts with local, Greg Wooledge, 2010/05/03
Re: Passing variables by reference conflicts with local, Marc Herbert, 2010/05/04