help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Is there a way to access a global variable once a local


From: Grisha Levit
Subject: Re: [Help-bash] Is there a way to access a global variable once a local variable with the same name is declared?
Date: Fri, 7 Dec 2018 15:03:25 -0500

That's some unofficial mirror. Official repo is at
https://git.savannah.gnu.org/cgit/bash.git, check the devel branch.

On Fri, Dec 7, 2018, 2:54 PM Peng Yu <address@hidden> wrote:

> Where is 5? I only see 4.4.
>
> https://github.com/bminor/bash
> On Fri, Dec 7, 2018 at 1:48 PM Grisha Levit <address@hidden> wrote:
> >
> > This is actually only in bash 5.
> >
> > On Fri, Dec 7, 2018, 2:31 PM Peng Yu <address@hidden> wrote:
> >>
> >> >    $ g() { declare -n $1=$1; printf %s "${!1}"; } 2>/dev/null
> >> >    $ x=1; f() { local x=2; g x; }; f
> >> >    1
> >>
> >> I don't see the "1" printed at the end. Anything wrong?
> >>
> >> --
> >> Regards,
> >> Peng
>
>
>
> --
> Regards,
> Peng
>


reply via email to

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