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

Re: Singleton arrays treated as scalars



Bart Schaefer wrote:

> I tried this again and got much better results for two-or-more element
> arrays, but singleton arrays were still getting subscripted as scalars.
> Investigation led me to this fragment of paramsubst():
> 
>         if (isarr > 0 && !plan9 && (!aval || !aval[0])) {
>             val = dupstring("");
>             isarr = 0;
>         } else if (isarr && aval && aval[0] && !aval[1]) {
>             val = aval[0];
>             isarr = 0;
>         }
> 
> Well, look at that.  If we have a singleton array, make it into a scalar.
> This doesn't have anything to do with multsub() at all!
> 
> Does anybody remember why this code is here?  What part of the world is
> going to come crashing down if that "else if" clause gets deleted?

When buildin the patch I just sent, I stumbled over this, too. And no, 
I have no idea whence this came or what would happen, if...

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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