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

Re: RC_EXPAND_PARAM final patch

Andrej Borsenkow wrote:
> Totally agreed. If I get it right, the patch does following:
>   make substitutions (converting $^a into {a[1],a[2],...}
>   word-split the result (it can result in lists in {...} being extended
>     if SH_WORD_SPLIT is set)
>   make brace expansion in each word (with implicit word splitting)

Yes.  The current mechanism is not exactly like this, but I'm goint to
change it and this is exactly I'm going to do.  Replace $^x with a brace
expansion list, and expand it later in together with other braces.
Currently there are several problems:

belgium ~ % echo {a,b}{x,y}
ax ay bx by

That fine.

belgium ~ % x=(x y)
belgium ~ % echo {a,b}$^x
ax bx ay by

Do you see the difference?  This is going to change.  The other problem:

belgium ~ % echo {$x,z}a
{x y,z}a

It is probably not what you would expect, although ksh behaves this way.
I'm goint to change it so that the result will be 3 words:

x ya za

But this would mean an other change: ${x}{a,b} will expand to 4 words,

x ya x yb

instead of the current x ya yb.  The current behaviour is the way ksh
behaves, and the planned new one is similar to bash (you can use $* and $@
to study the behaviour of arrays in bash and ksh).

> > Here a${(e)^foo}b${(e)foo} is substituted to two identical
> > a$[i++]b${(e)foo} arguments, and substitution for these arguments is
> > started from the beginning.
> It is the most surprising thing I ever seen in ZSH!!! _NO_ word in manuals
> ever suggested such interpretation. I was always shure that
> ${(e)a} just gets recursivly expanded, which is what I call consistent and

The (e) stuff is completely broken, this will be fixed and it'll work like
you'd expect.


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