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

Re: Singleton arrays treated as scalars



Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> typed:
: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?

It's a pf artifact.  Looking in 2.00.03 sees it there in a slightly
different incantation but logically the same.
-- 
Geoff Wing   <gcw@xxxxxxxxx>            Mobile : (Australia) 0412 162 441
Work URL: http://www.primenet.com.au/   Ego URL: http://pobox.com/~gcw/



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