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

Re: RC_EXPAND_PARAM final patch



On Sat, 2 Aug 1997, Zoltan Hidvegi wrote:

> 
> This is consistent, predictable, and the implementation is simple.
> 

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)

Correct? Could anybody with better English ;) add description of how ZSH
relly works to zshexpn(1)? 

> There is still one point where the behaviour might be surprising: that's
> when the (e) substitution flag is used:
> 
> % echo ${x}1${(e)^a}2${x}
> x y1a2x y y1b2x y
> 
> With the (e) flag, the behaviour is the same as it was with
> zsh-2.6-beta16 and earlier.  This is related to this behaviour:
> 
> % integer i=0
> % foo=('$[i++]' '$[i++]')
> % echo a${(e)^foo}b${(e)foo} 
> a0b1 2 a3b4 5
> 
> 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
predictable ;-) Consider

a=('$[i++]' '$[i++]')
i=0
echo ${(e)^a}${(e)a}
01 2 34 5
i=0
echo ${(e)a}${(e)^a}
0 12 13

I hardly can call it `consistent'. If every expression were evaluated
first, we would get '02 12 3' and '0 12 13' which _is_ predictable - every
${...} is evaluated and combined using well-known rules.

Honestly speaking, how would you describe current behaviour in plain
words?

                              This is exatly the zsh-2.6-beta16 behaviour.
> This can be (or maybe, should be) changed, but that would require much
> more complicated changes. 

I understand, why it was implemented this way, but what's wrong with just
calling stringsubst for the result of ${(e)...} expansion?

                             Since most people probably do not even know
> about the (e) flag, this would not affect too many scripts.  

But if anybody would like to use it, he needs clear picture what to expect
(I still have to find out most things by trial-and-error :(

-------------------------------------------------------------------------
Andrej Borsenkow 		Fax:   +7 (095) 252 01 05
SNI ITS Moscow			Tel:   +7 (095) 252 13 88

NERV:  borsenkow.msk		E-Mail: borsenkow.msk@xxxxxx
-------------------------------------------------------------------------





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