bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Difference between assignment via nameref vs `printf -v`?


From: Pierre Gaston
Subject: Re: Difference between assignment via nameref vs `printf -v`?
Date: Sun, 31 Aug 2014 23:55:01 +0300

On Sun, Aug 31, 2014 at 7:19 PM, lolilolicon <lolilolicon@gmail.com> wrote:

> On Sun, Aug 31, 2014 at 12:20 PM, lolilolicon <lolilolicon@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]'


reply via email to

[Prev in Thread] Current Thread [Next in Thread]