help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] Walkaround for the limitation of declare -n


From: Koichi Murase
Subject: Re: [Help-bash] Walkaround for the limitation of declare -n
Date: Mon, 21 Jan 2019 20:13:45 +0900

Hi,

> Given the above limitation (without having to upgrade the
> developmental version), is there a good walk-around to avoid naming
> conflict?

I think you can use Freddy Vulto's `upvar' trick which does not rely
on `declare -n':
http://www.fvue.nl/wiki/Bash:_Passing_variables_by_reference

--
Regards,
Koichi

2018年12月13日(木) 13:57 Peng Yu <address@hidden>:
>
> Hi,
>
> https://mywiki.wooledge.org/BashFAQ/048
> "The problem with bash's name references"
>
> $ foo() { declare -n v=$1; }
> $ bar() { declare -n v=$1; foo v; }
> $ bar v
> bash: warning: v: circular name reference
>
> Given the above limitation (without having to upgrade the
> developmental version), is there a good walk-around to avoid naming
> conflict? I still would like to use the same name in different
> functions. But this limitation forces that I have to use different
> names if I need to call one function from another using reference.
>
> --
> Regards,
> Peng
>



reply via email to

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