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 14:48:46 -0500

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
>


reply via email to

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