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: Peng Yu
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 13:31:14 -0600

>    $ 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]