Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: array prepend

On Mon, Jan 14, 2013 at 9:02 PM, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>wrote:

> On Jan 14, 10:18am, rahul wrote:
> }
> } I was wondering what the way for inserting into an array is. Is the
> } following the simplest or most direct way:
> }
> }     $FOO[1,2] xxx $FOO[3,-1]
> Probably
>         FOO[N]+=(xxx)
> Note this is distinct from
>         FOO[N]+=xxx
> which will string-append xxx to the value stored at $FOO[N].

Wow! I was not going to ask this, since i have been asking too many
questions, but after reading your reply I can't resist asking this.

I was hoping to assign lists (arrays) to an associative array, and got the
error which is well documented on the internet. But no one has given any
workaround or alternative to this.

   FOO[a]=("a command" "some text" "etc etc")

zsh: FOO: attempt to set slice of associative array

Is the only alternative to do the following:

FOO_a=( a list)
FOO_b=(another list)

thx,  rahul

Messages sorted by: Reverse Date, Date, Thread, Author