Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14357

Re: delcare -a on a nameref in a function modifies nameref instead of target

From Greg Wooledge <wooledg@eeg.ccf.org>
Newsgroups gnu.bash.bug
Subject Re: delcare -a on a nameref in a function modifies nameref instead of target
Date 2018-07-18 08:23 -0400
Message-ID <mailman.3753.1531916620.1292.bug-bash@gnu.org> (permalink)
References <CAMu=BrqTimtENjRABPgRdDhn5bQG2zBMv5YfQsNQDETh6oAjeQ@mail.gmail.com>

Show all headers | View raw


On Tue, Jul 17, 2018 at 05:47:20PM -0400, Grisha Levit wrote:
> At global scope this works as expected:
> 
> $ declare -n ref=var; declare -a ref=(X); declare -p ref var
> declare -n ref="var"
> declare -a var=([0]="X")
> 
> But in a function, we end up with the nameref variable having both the
> `a' and `n' attributes and nothing in the target:
> 
> $ f() { declare -n ref=var; declare ref=(X); declare -p ref var; }; f
> declare -an ref=([0]="X")
> -bash: declare: var: not found

FYI that one is already fixed in 5.0-alpha:

wooledg:~$ declare -n ref=var; declare -a ref=(X); declare -p ref var
declare -n ref="var"
declare -a var=([0]="X")
wooledg:~$ f() { declare -n ref=var; declare ref=(X); declare -p ref var; }; f
declare -an ref=([0]="X")
declare -a var=([0]="X")

Or at least partly fixed. *shrug*

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Re: delcare -a on a nameref in a function modifies nameref instead of target Greg Wooledge <wooledg@eeg.ccf.org> - 2018-07-18 08:23 -0400

csiph-web