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

Re: RC_EXPAND_PARAM bug



Bart Schaefer wrote:
> On Jul 28,  2:42pm, Andrew Main wrote:
[...]
> } % a=(a b)
> } % x=(x y)
> } % echo ${^a}1${^x}
> } a1y b1x b1y
> } 
> } ?
> 
> It gets weirder:
> 
> % echo 1${^a}1${^^x}
> 1ay 1b1x 1by

Below is a fix.  The second expansion might still look a bit weird:

% echo 1${^a}1${^^x}
1a1x 1ay 1b1x 1by


The logic is that the string after the rc-param, 1${^^x}, is expanded,
producing two strings, 1x y, which is combined with 1a 1b.  It is true
that this is incompatible with 2.6-beta16 and older, which first expanded
it to 1a1${^^x} 1b1${^^x} and later this was expanded to 1a1x y 1b1x y.
Similarily, let i=0; echo ${^a}$[i++] expanded to a$[i++] b$[i++] and
later to a0 b1, while in zsh-3.0.4 it expands to a0 b0.

Zoltan


*** Src/subst.c	1997/06/17 05:53:19	3.1.3.2
--- Src/subst.c	1997/07/29 05:40:45
***************
*** 1423,1430 ****
  			      (char *) getdata(tn), globsubst);
  		    if (qt && !*y && isarr != 2)
  			y = dupstring(nulstring);
! 		    if (i == 1)
! 			setdata(n, (void *) y);
  		    else
  			insertlinknode(l, n, (void *) y), incnode(n);
  		}
--- 1423,1430 ----
  			      (char *) getdata(tn), globsubst);
  		    if (qt && !*y && isarr != 2)
  			y = dupstring(nulstring);
! 		    if (plan9)
! 			setdata(n, (void *) y), plan9 = 0;
  		    else
  			insertlinknode(l, n, (void *) y), incnode(n);
  		}



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