[Top][All Lists]

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

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

From: lolilolicon
Subject: Re: Difference between assignment via nameref vs `printf -v`?
Date: Mon, 1 Sep 2014 03:09:24 +0800

On Sun, Aug 31, 2014 at 12:20 PM, lolilolicon <address@hidden> 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='()'

The bug does not affect global nameref variables,

  declare -a arr
  declare -n ref
  declare -p 'arr[0]' arr

  --- output ---
  gn.sh: line 5: declare: arr[0]: not found
  declare -a arr='([0]="foo")'

reply via email to

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