[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:53:49 -0600 |
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