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.
>
> typeset -a x
>
> function f
> { # ...
> x=([0]=a [3]=b)
> # ...
> }
>
> A call to f would make x associative, which I don't want. So I'm forced to
> use
>
> f()
> { # ...
> typeset -a x=([0]=a [3]=b)
> # ...
> }
>
> But this makes all auxiliary variables in f global, which I don't want
> either. A way out of this dilemma would be to change the behaviour of the
> typeset-less assignment so that it leaves the 'indexed' attribute intact.
The += will give you what you want once I supply the fix.
>
> 2. On my Linux box, the sequence
>
> typeset -a x
> typeset
>
> causes the shell to crash with a memory fault. I'm using the 2007-11-05
> version.
I will fix this bug as well. This is a really simple one.
>
> Regards,
> Bernd
>
> --
> Bernd Eggink
> [EMAIL PROTECTED]
> http://sudrala.de
David Korn
[EMAIL PROTECTED]
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers