On 10 July 2013 22:18, David Korn <[email protected]> wrote: > cc: [email protected] > Subject: Re: ksh93 returns "()" for "${a[@]}" if I clear an array with a=( ) > -------- > >> ksh93 returns "()" for "${a[@]}" if I clear an array with a=( ) > > > a=() > > doesn't clear an array, it unsets a and creates an empty compound variable > ( > ) > > typeset -a a=() > > should clear an array.
This is not very intuitive. First variable a has already be declared as an array so the intuitive feeling would be that a=() resets it with an empty array. 2nd your interpretation assumes that the called function knows the array data type to reset it - which becomes a pain if you have hundreds of types defined and try to use a utility function which should reset an array of any of these types. I'd better go for: a=() means reset the variable if variable a is either array or compound. If it isn't already a type of these make it a compound variable. If variable a is of type integer or string throw an error. This should make things more predictable. Ced -- Cedric Blancher <[email protected]> Institute Pasteur _______________________________________________ ast-users mailing list [email protected] http://lists.research.att.com/mailman/listinfo/ast-users
