[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: nameref and referenced variable scope, setting other attributes (was
From: |
Greg Wooledge |
Subject: |
Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope) |
Date: |
Thu, 14 Mar 2024 09:53:37 -0400 |
On Thu, Mar 14, 2024 at 08:29:47AM -0400, Zachary Santer wrote:
> Alright, that's all fair. But this?
>
> On Sun, Mar 10, 2024 at 7:29 PM Zachary Santer <zsanter@gmail.com> wrote:
> >
> > Additionally, a nameref variable referencing a variable declared in a
> > calling function hides that variable in the scope of the function where the
> > nameref variable is declared.
>
I don't quite understand what this is saying. Do the variables have
different names, or the same name? If they have different names, then
the nameref shouldn't "hide" the other variable. But they can't have
the same name, because a nameref pointing to itself is a circular
reference and won't ever work under any circumstance.
hobbit:~$ f() { local -n var=var; var=1; }; f
bash: local: warning: var: circular name reference
bash: warning: var: circular name reference
bash: warning: var: circular name reference
You don't even need an outer calling function to see this.
- "local -g" declaration references local var in enclosing scope, Adrian Ho, 2024/03/10
- Re: "local -g" declaration references local var in enclosing scope, Kerin Millar, 2024/03/10
- Re: "local -g" declaration references local var in enclosing scope, Zachary Santer, 2024/03/10
- nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Zachary Santer, 2024/03/10
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Chet Ramey, 2024/03/13
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), alex xmb sw ratchev, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Greg Wooledge, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), alex xmb sw ratchev, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Zachary Santer, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope),
Greg Wooledge <=
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Zachary Santer, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Greg Wooledge, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Zachary Santer, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Chet Ramey, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), alex xmb sw ratchev, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Robert Elz, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Chet Ramey, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Zachary Santer, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Zachary Santer, 2024/03/14
- Re: nameref and referenced variable scope, setting other attributes (was "local -g" declaration references local var in enclosing scope), Chet Ramey, 2024/03/14