[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Syntax Question...
From: |
Pierre Gaston |
Subject: |
Re: Syntax Question... |
Date: |
Thu, 18 Aug 2011 17:21:57 +0300 |
On Thu, Aug 18, 2011 at 5:13 PM, Linda Walsh <bash@tlinx.org> wrote:
>
>
>
> Pierre Gaston wrote:
>>
>> On Mon, Aug 15, 2011 at 2:31 AM, Linda Walsh <bash@tlinx.org> wrote:
>>
>>>
>>> Re: BashFAQ/006: http://mywiki.wooledge.org/BashFAQ/006
>>> Pierre Gaston wrote:
>>>
>>>>
>>>> Linda:
>>>>
>>>>>
>>>>> please show quote the section
>>>>> that shows using an variable that holds the name of an array to be used
>>>>> (and assigned to).... else ..
>>>>>
>>>>
>>>> The proof is in the faq, you could have found it if you were not busy
>>>> trolling the list.
>>>>
>>>
>>> ====
>>> Guess this was not possible. The FAQ covers indirect,
>>> it covers arrays, but I see no place where it covers the combination.
>>> If you see such, then quote it. Don't just wave your arms around
>>> making unsubstantiated claims or accusations.
>>>
>>> I didn't ask for the impossible -- just a quote.
>>>
>>> Apparently that was too much to ask for, so you call me a troll
>>> ....ya, right. Who's the troll?
>>>
>>
>> # Bash -- trick #1. Seems to work in bash 2 and up.
>> realarray=(...) ref=realarray; index=2
>> tmp="$ref[$index]"
>> echo "${!tmp}" # gives array element [2]
>>
>
> ----
>
> Ok I'll give you credit for, being serious in believing the page answered
> my qustion....
>
> But my question was: what was the syntax to do: to use an
> indirect array reference directly to reference members of the array, as
> indicated in my failed example:
>
>> echo ${#${!name}[*]}
>
> bash: ${#${!name}[*]}: bad substitution
> # note that ${#<arrname>[*(or @)]} will give you the num elements in
> the array. I wanted to sub in '${!var} for 'arrname' in order to
>
> ---
> Michael Witten, immediate got the issues I was trying to avoid and
> responded:
>
> It's probably what you're trying to avoid, but you'll probably have to
> construct and then eval the right code by hand:
>
> $(eval "echo \${#$name[*]}")
> ----
> I was trying to avoid any workaround that used
> one or more multiple common workarounds like evals and/or
> use of tmp vars... I.e. I saw no such syntax.
>
> As others confirmed: such syntax is NOT
> possible in the current bash. It was in the context of that, when you
> indicated there was an answer to my
> 'how to do syntax for xxyz'
>
> on the page in question and thus my need to have
> you explain what you meant (via a quote showing the
> use of such).
>
> I now understand that you thought such a response would suffice.
> Perhaps you also understand
> why that's not what I was looking for.
>
> *peace*
> linda
l understood a while ago, now I'll just stop feeding the troll.
- Re: Syntax Question..., (continued)
- Re: Syntax Question..., Greg Wooledge, 2011/08/17
- Re: Syntax Question..., Ken Irving, 2011/08/16
- Re: Syntax Question..., Dennis Williamson, 2011/08/16
- Re: Syntax Question..., Linda Walsh, 2011/08/16
- Re: Syntax Question..., Ken Irving, 2011/08/16
- Re: Syntax Question..., Greg Wooledge, 2011/08/17
- Re: Syntax Question..., Linda Walsh, 2011/08/19
- Re: Syntax Question..., Linda Walsh, 2011/08/16
- Re: Syntax Question..., Pierre Gaston, 2011/08/15
- Re: Syntax Question..., Linda Walsh, 2011/08/18
- Re: Syntax Question...,
Pierre Gaston <=
- Re: Syntax Question..., Linda Walsh, 2011/08/18