Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14366
| From | Grisha Levit <grishalevit@gmail.com> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | Re: delcare -a on a nameref in a function modifies nameref instead of target |
| Date | 2018-07-19 13:20 -0400 |
| Message-ID | <mailman.3827.1532020833.1292.bug-bash@gnu.org> (permalink) |
| References | <CAMu=BrqTimtENjRABPgRdDhn5bQG2zBMv5YfQsNQDETh6oAjeQ@mail.gmail.com> <20180718122303.qlehxuzdphatfke7@eeg.ccf.org> |
On Wed, Jul 18, 2018 at 8:23 AM Greg Wooledge <wooledg@eeg.ccf.org> wrote:
> 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*
I think you are just seeing `var' have a value after the function call
because it's still there from the global `declare' invocations.
With bash 5.0 alpha, running just the version that's wrapped in a
function, I don't get any value for `var':
$ echo $BASH_VERSION
5.0.0(1)-alpha
$ f() { declare -n ref=var; declare ref=(X); declare -p ref var; }; f
declare -an ref=([0]="X")
bash: declare: var: not found
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: delcare -a on a nameref in a function modifies nameref instead of target Grisha Levit <grishalevit@gmail.com> - 2018-07-19 13:20 -0400
csiph-web