David Korn schrieb:
cc:  [EMAIL PROTECTED] [EMAIL PROTECTED]
Subject: Re: [ast-developers] Two array assignment problems
--------

1. The assignment

     typeset -a x=(a b c)

makes an indexed array x, but a subsequent

     x=([0]=a [2]=b [5]=c)

turnes x into an associative array - against my declared will, and for no obvious reason. On the other hand, the statement

     typeset -a x=([0]=a [2]=b [5]=c)

creates an indexed array, though the right side has exactly the same form as above. This looks inconsistent to me, and also causes problems when assigning values to elements of a global array in a function. Example:
Actually, the array  assignment should unset the variable before
the assignment so that x should be an associative array and have only
three elements.
     x+=([0]=a [2]=b [5]=c)
should modify/add elements to the indexed array.  However, there is
a bug here and the array is being converted to an associative array.
I will fix this and in the case you describe, I will first unset the
variable x before the assignment.

Hm, just to make things clear: I'm writing a 'function vared' which allows editing of variables of any kind. It uses an editor and a temporary file, which is sourced after editing. So

    typeset -a x=([1]=a [3]=b)
    vared a

generates a line like

    x=([1]=a [3]=b)

in the file, which the user may change at his will, e.g.

    x=([1]=a [5]=c)

Do I understand you right that this would make x associative again, but the following would work?

    x=()
    x+=([1]=a [5]=c)    

Regards,
Bernd

--
Bernd Eggink
[EMAIL PROTECTED]
http://sudrala.de
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to