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

Re: ls $PWD/<TAB>



Tanaka Akira wrote:

> I found that filenames are not completed when a variable is used.
> 
> is27e1u11% bindkey -e; autoload -U compinit; compinit -D
> is27e1u11% ls $PWD/<TAB>
> 
> is27e1u11% a=.
> is27e1u11% ls $a/<TAB>
> 
> They copmletes nothing.

parse_subst_string() modified the value of a parameter if that wasn't
copied yet.

The hunk in strcatsub() is just a bit of cleanup... I first thought
the bug were there.

Bye
 Sven

--- ../z.old/Src/subst.c	Tue Feb 29 13:11:04 2000
+++ Src/subst.c	Tue Feb 29 16:59:08 2000
@@ -428,7 +428,7 @@
     int pl = pe - pb;
 
     if (!pl && (!s || !*s)) {
-	dest = (*d = (copied ? src : dupstring(src)));
+	*d = dest = (copied ? src : dupstring(src));
 	if (glbsub)
 	    tokenize(dest);
     } else {
@@ -701,9 +701,13 @@
 
 /* Parsing for the (e) flag. */
 
-static int
-subst_parse_str(char *s, int single)
+static char *
+subst_parse_str(char **sp, int single)
 {
+    char *s;
+
+    *sp = s = dupstring(*sp);
+
     if (!parsestr(s)) {
 	if (!single) {
 	    for (; *s; s++)
@@ -1788,7 +1792,7 @@
 		if (prenum || postnum)
 		    x = dopadding(x, prenum, postnum, preone, postone,
 				  premul, postmul);
-		if (eval && subst_parse_str(x, (qt && !nojoin)))
+		if (eval && subst_parse_str(&x, (qt && !nojoin)))
 		    return NULL;
 		xlen = strlen(x);
 		for (tn = firstnode(&tl);
@@ -1824,7 +1828,7 @@
 	    if (prenum || postnum)
 		x = dopadding(x, prenum, postnum, preone, postone,
 			      premul, postmul);
-	    if (eval && subst_parse_str(x, (qt && !nojoin)))
+	    if (eval && subst_parse_str(&x, (qt && !nojoin)))
 		return NULL;
 	    xlen = strlen(x);
 	    strcatsub(&y, ostr, aptr, x, xlen, NULL, globsubst, copied);
@@ -1839,7 +1843,7 @@
 		if (prenum || postnum)
 		    x = dopadding(x, prenum, postnum, preone, postone,
 				  premul, postmul);
-		if (eval && subst_parse_str(x, (qt && !nojoin)))
+		if (eval && subst_parse_str(&x, (qt && !nojoin)))
 		    return NULL;
 		if (qt && !*x && isarr != 2)
 		    y = dupstring(nulstring);
@@ -1855,7 +1859,7 @@
 	    if (prenum || postnum)
 		x = dopadding(x, prenum, postnum, preone, postone,
 			      premul, postmul);
-	    if (eval && subst_parse_str(x, (qt && !nojoin)))
+	    if (eval && subst_parse_str(&x, (qt && !nojoin)))
 		return NULL;
 	    xlen = strlen(x);
 	    *str = strcatsub(&y, aptr, aptr, x, xlen, fstr, globsubst, copied);
@@ -1874,7 +1878,7 @@
 	if (prenum || postnum)
 	    x = dopadding(x, prenum, postnum, preone, postone,
 			  premul, postmul);
-	if (eval && subst_parse_str(x, (qt && !nojoin)))
+	if (eval && subst_parse_str(&x, (qt && !nojoin)))
 	    return NULL;
 	xlen = strlen(x);
 	*str = strcatsub(&y, ostr, aptr, x, xlen, fstr, globsubst, copied);

--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



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