On Thursday, November 29, 2012 11:12:50 PM Roland Mainz wrote:
> Erm... what exactly do you want to do in this case ? The example above
> contains a wild mixture of everything... including things which are
> corner-cases... like adding compound variables to a plain string array
> (which is AFAIK only allowed for legacy purposes since now we have
> typeset -C to explicitly declare an array of compound variables) and
> mixing dimensions in a multi-dimensional array (AFAIK
> multi-dimensional arrays should only have one number of dimensions and
> not multiple numbers of dimensions).
>
> ----
>
> Bye,
> Roland
>
I don't completely understand which of these are expected or why they differ.
In the case of one-dimensional array declarations there are typically multiple
ways of doing the same thing. Either "typeset -a arr" or "typeset -a arr=()"
declare the array variable itself or the outermost type as an indexed array,
and operations on the zeroth element of an array (usually but not always) are
a synonym for an operation on the array variable.
I also assumed that arr[n]=(), and arr=([n]=()) mean to set the nth element of
an array to an empty array, and arr=( () ) sets the zeroth element to an empty
array. I don't really see the pattern of how types of inner variables at
various levels of nesting are determined by combinations of attribute flags
and which kinds of compound assignment syntax is used. For instance, the
combination of -a and -C doesn't seem to do anything other than alter the
output of typeset -p, though the order of the flags seems to be significant,
and going through a nameref can also make a difference. I couldn't possibly
remember all the surprising cases I've come across.
"Setness" of a variable is also confusing and differs between shells.
Apparently ksh considers an empty indexed array as "set" according to "typeset
-p", and unset according to [[ -v var ]], [[ -v var[0] ]], and the "${var+}"
expansion, while an empty compound array is considered declared according to
everything.
Also, thanks for all you've posted to this list... your code samples are
nearly the only non-trivial ones which make use of current features that I've
been able to find anywhere.
--
Dan Douglas
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users