On 2/18/19 1:44 PM, L A Walsh wrote:
> 
> 
> On 2/17/2019 6:54 PM, Chet Ramey wrote:
>> Not quite. Dynamic variables are only defined to return the correct value
>> when they are referenced. The rest of the time, the values are
>> indeterminate (and possibly stale). The idea is that you can get an element
>> given the right index, or all the elements with the `*' or `@' subscripts.
>>
>> ...
>>
>> `declare -p' just lists variables and any existing values. It doesn't cause
>> values to be generated. `declare -p BASH_ALIASES' counts as asking for the
>> value.
>>
>>   
> Thanks for the more thorough explanation. 
> 
> Was wondering if it would be possible (or worth it) on arrays and
> hashes, where the current value isn't shown, if the number of entries
> stored, might be shown?  That way more people might know that the
> declare -p output may only be giving names (and, maybe size) even if
> not enumerated.

If the value shows up as empty, as when the value hasn't yet been
computed, the number of entries is zero.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU    c...@case.edu    http://tiswww.cwru.edu/~chet/

Reply via email to