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

Re: PATCH: Icky little array slice assignment bug

I wrote:
} That is, there's a phantom element at the right end of an array but not at
} the left, so you can "push" but not "unshift" elements -- an attempt to
} insert at the beginning of the array clobbers the first element.

Looking back at the ChangeLog-Release for several of the patches related
to 11677 caused me to try this:

zagzig% a[1,0]=(a b c)
zagzig% echo $a
a b c
zagzig% a[1,0]=(x y z)
zagzig% echo $a
x y z a b c

Well, whaddya know; you CAN do an "unshift", you just have to use a
seemingly-impossible range to accomplish it.

However, it demonstrates that my first patch didn't cover all cases (so
I have not committed it yet):

zagzig% a=(a b c)
zagzig% a[2,(R)q]=x
zagzig% echo $a
a x a b c
zagzig% a[3,(R)q]=y
zagzig% echo $a
a x y a x a b c

I'm not quite sure what to do about this.  Wayne?

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

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