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

PATCH: Re: Prompt %~ (sometimes) expands /local/src/zsh to ~unambiguous



On Jun 28, 10:48am, Peter Whaite wrote:
} 
} I have noticed that every now and then `print -P "%~"` prints "~unambiguous".

On Jun 28,  4:55pm, Sven Wischnowsky wrote:
}
} Haven't investigated any further... the $compstate assoc contains an
} element `unambiguous'. Maybe one of the recent changes to the
} parameter code...?

I don't know if it's one of the recent changes, but that does appear to
be the problem:

zagzig% setopt autonamedirs
zagzig% typeset -A foo
zagzig% foo[bar]=$PWD
zagzig% print -P %~
~bar

} And maybe we should add code to prevent the automatic name-dir
} behaviour for assoc elements anyway (if we don't have that already and 
} this is really the cause).

Actually, I have a longstanding request that ~foo[bar] should work ...
but that means changing the parser ...

Certainly assigning to foo[bar] shouldn't define ~bar.

Index: Src/params.c
===================================================================
@@ -2020,6 +2020,7 @@
 	oldpm = pm->old;
 	paramtab->addnode(paramtab, oldpm->nam, oldpm);
 	if ((PM_TYPE(oldpm->flags) == PM_SCALAR) &&
+	    !(pm->flags & PM_HASHELEM) &&
 	    oldpm->sets.cfn == strsetfn)
 	    adduserdir(oldpm->nam, oldpm->u.str, 0, 0);
 	if (oldpm->flags & PM_EXPORTED) {
@@ -2104,7 +2105,8 @@
 {
     zsfree(pm->u.str);
     pm->u.str = x;
-    adduserdir(pm->nam, x, 0, 0);
+    if (!(pm->flags & PM_HASHELEM))
+	adduserdir(pm->nam, x, 0, 0);
 }
 
 /* Function to get value of an array parameter */

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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