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

Re: Singleton arrays treated as scalars (redux)



Bart Schaefer wrote:

> I think I've figured out why paramsubst() converts one-element arrays into
> scalars.  Consider the case where zsh needs to expand
> 
> 	some${param}thing
> ...
> 
> The one-element array case can't be handled like the two-or-more case; it
> must be handled like the scalar case.  So zsh does the simplest thing, and
> turns the array into a scalar so that it will take that code branch.  This
> also prevents it from attempting plan9 (rcexpandparam) concatenation when
> there is only one element.

Aha.

> However, there's one spot where I think mult_isarr is not correctly set,
> and another spot where isarr is compared to 2 even though in that branch
> it can't possibly have any value other than 0.  Patch appended, someone
> please check it for sanity.

As far as I can see, this looks good (I saw this superfluous isarr!=2, 
too, when playing with mult_isarr, I was just to superstitious to
remove it).


Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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