cc: rbtneville at gmail.com
Subject: Re: [ksh93-integration-discuss] Dereferencing an array name reference
--------


> While educating myself about the new ksh features I stumbled over a
> behaviour which I do not understand. The example below tries to
> dereference a name reference but only returns the name of the variable
> but not the array index:
> % ksh93
> $ typeset -A a
> $ a[x]=5
> $ nameref l=a[x]
> echo "${!l}"'
> a
> 
> I expected a[x] as output. Is this a bug or do name references only
> apply to variables and not their index?
> -- 
> robert neville - it consultant


I will classify this as a bug and it also uncovers another bug
or at least undocumented behavior.

Currently,
        ${!x}
should provide the name for variable x following references, so
it should have displayed a[x] in this case.  (I will fix this
and also will not allow the [..] to be treated as a character class
even if not quoted.

Currently ${...@]} or ${!x[*]} expand to the subscripts (or 0 if x is
not subscripted).

However, the behavior of
        ${!x[foo]}
is currently undocumented and currently outputs foo.  This will be changed
to output
        x[foo]
so that
        ${!x[2+2]}
will output
        x[4]

This will be in ksh93t.



David Korn
dgk at research.att.com

Reply via email to