On Sun, Aug 31, 2014 at 7:19 PM, lolilolicon <loliloli...@gmail.com> wrote:
> On Sun, Aug 31, 2014 at 12:20 PM, lolilolicon <loliloli...@gmail.com> > wrote: > > Assignment to a subscripted array variable behaves differently for > > nameref vs `printf -v`, as shown below. > > > > Assignment via nameref variable: > > > > declare -a arr=() > > func() { > > local -n ref=$1 > > ref='nameref' > > } > > func 'arr[0]' > > declare -p 'arr[0]' arr > > > > --- output --- > > declare -- arr[0]="nameref" > > declare -a arr='()' > > It's a damn bug alright. Just curious though, shouldn't assignments to > via nameref variables re-use the same code as `printf -v`? > > Not sure what makes this bug a damned one, but it's probably because it re-uses the same code that it doesn't make an extra check and creates this invalid variable name 'arr[0]'