Re: Stumped on a question of scoping and unset.

2011-05-26 Thread Andreas Schwab
Freddy Vulto writes: > On 09:11, Steven W. Orr wrote: >> typeset $1 && upvars -a$nn $1 "${aval[@]}" >> >> The implication seems to be that the typeset command can fail. Is >> this a reasonable thing to worry about? > > The idea is that a typeset - besides declaring a variable local - > protects

Re: Stumped on a question of scoping and unset.

2011-05-26 Thread Freddy Vulto
On 09:11, Steven W. Orr wrote: > typeset $1 && upvars -a$nn $1 "${aval[@]}" > > The implication seems to be that the typeset command can fail. Is > this a reasonable thing to worry about? The idea is that a typeset - besides declaring a variable local - protects upvars from malicious variable nam

Re: Stumped on a question of scoping and unset.

2011-05-26 Thread Steven W. Orr
On 5/26/2011 8:18 AM, Greg Wooledge wrote: On Wed, May 25, 2011 at 05:15:28PM -0400, Steven W. Orr wrote: In addition, I wrote (what I thought was pretty clever) a function called glob_array: glob_array() { [[ snip ]] while (( $# )) do arrayname=$1 pattern="$2"

Re: Stumped on a question of scoping and unset.

2011-05-26 Thread Greg Wooledge
On Wed, May 25, 2011 at 05:15:28PM -0400, Steven W. Orr wrote: > In addition, I wrote (what I thought was pretty clever) a function > called glob_array: > glob_array() > { [[ snip ]] > while (( $# )) > do > arrayname=$1 > pattern="$2" > aval=( $pattern ) Looks li

Re: Stumped on a question of scoping and unset.

2011-05-26 Thread Freddy Vulto
On 05:15, Steven W. Orr wrote: > * Why is it needed to use the unset? > * What does unset -v do extra for me? > * What bad things could happen if I don't do the unset? Upvars makes use of unset's capability of traversing down the call-stack: a=0 b=0 c=0 d=0 e=0 _unset() { unset -v b c c d