bug-bash
[Top][All Lists]
Advanced

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

Re: Indirect access to variables, including arrays (was Re: Compare 2 ar


From: Pierre Gaston
Subject: Re: Indirect access to variables, including arrays (was Re: Compare 2 arrays.)
Date: Thu, 7 Jun 2012 15:28:53 +0300

On Thu, Jun 7, 2012 at 12:27 PM, Dan Douglas <ormaaj@gmail.com> wrote:
> On Thursday, June 07, 2012 10:01:51 AM Pierre Gaston wrote:
>> On Thu, Jun 7, 2012 at 6:07 AM, Linda Walsh <bash@tlinx.org> wrote:
>> >(no I haven't made it space/bracket...whatever proof...just a bit
>> > more work)
>>
>> It's not just "a bit more work", there are many workarounds but it's not
>> really possible to make a really robust generic solution for assignment,
>> and in the end it just not as simple and pretty as nameref.
>>
>> Fwiw here is a robust and simple solution for in_:
>>
>> _in () {
>>   local e t
>>   t="${2:?}[@]";
>>   for e in "${!t}"; do [[ $1 = "$e" ]] && return 0;done
>>   return 1;
>> }
>>
>
> Not robust due to the name conflicts with "e" or "t". There's also no good way
> to generate a list of locals without parsing "local" output (i'd rather live
> with the conflicts). I usually store indirect references in the positional
> parameters for that reason. Proper encapsulation is impossible.

Ah true, thanks for the reminder that also kinda prove my first point.



reply via email to

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