On Fri, Apr 30, 2010 at 12:02:58AM +0200, Freddy Vulto wrote: > In an attempt to improve the bash-completion package we're trying to > improve the bash completion library functions by passing variables by > reference.
http://mywiki.wooledge.org/BashFAQ/006 > Passing variables by reference however, has a caveat in that > local variables override the passing by reference, e.g.: > > t() { > local a > eval $1=b > } > unset a; t a; echo $a # Outputs nothing, expected "b" Why did you declare 'a' to be local if that's not what you wanted? Why did you expect 'b' to be output, if you used a local variable? > I'm thinking of some workarounds below? All your workarounds still declare a local variable, which for some reason you expect to be treated as non-local. Stop doing that. $ t() { eval $1=b; }; unset a; t a; echo "a is '$a'" a is 'b'