[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: declare -n next=arr[++elem] == nowork ? [[ -v
From: |
Chet Ramey |
Subject: |
Re: declare -n next=arr[++elem] == nowork ? [[ -v |
Date: |
Tue, 9 Mar 2021 12:13:00 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 |
On 3/8/21 11:19 AM, Alex fxmbsw7 Ratchev wrote:
thank you for your answer
i have a question about [[ -v $next ]] i havent tried but you say it works
it would ? expand $next but wont it then check '[[ -v <content_of_next> ]]'
and fail ?
Try it. -v will evaluate an array reference with a subscript to see if that
particular element exists, but the general nameref resolution code does not
(and should not) re-evaluate an array expansion.
ill benchmark the usage of : $next ; before [[ -v now, if its minimal its
all fine i can use
i just remember it used to work
I doubt it, but it doesn't matter now.
for the [[ -v arr[++elem] ]] style i do cause i can add in the loop to the
array and it continues over the new elements, till no more
Come on, so does iterating from 0 to ${#arr[@]}.
i also have another this-same-declare issue with a more complex data structure
I think help-bash would be a good place for that discussion.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/