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

Re: BUG: locals remove setopt autonamedirs



Here is a patch that restricts AND to global parameters that doesn't depend on workers/54299:

Only ever turn global parameters into named directories

Philippe

diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index a7e862c70..85bf0b28a 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -240,7 +240,7 @@ pindex(AUTONAMEDIRS)
 pindex(NOAUTONAMEDIRS)
 cindex(directories, named)
 item(tt(AUTO_NAME_DIRS))(
-Any parameter that is set to the absolute name of a directory
+Any global parameter that is set to the absolute name of a directory
 immediately becomes a name for that directory, that will be used
 by the `tt(%~)'
 and related prompt sequences, and will be available when completion
diff --git a/Src/params.c b/Src/params.c
index 461e02acf..d29481923 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -2783,7 +2783,7 @@ assignstrvalue(Value v, char *val, int flags)
                  * overwriting bytes in already allocated string */
 		memcpy(z + v->start, val, vlen);
 		/* Implement remainder of strsetfn */
-		if (!(pm->node.flags & PM_HASHELEM) &&
+		if (!(pm->node.flags & PM_HASHELEM) && !pm->level &&
 		    ((pm->node.flags & PM_NAMEDDIR) ||
 		     isset(AUTONAMEDIRS))) {
 		    pm->node.flags |= PM_NAMEDDIR;
@@ -3940,11 +3940,6 @@ unsetparam_pm(Param pm, int altflag, int exp)
     if (pm->old) {
 	oldpm = pm->old;
 	paramtab->addnode(paramtab, oldpm->node.nam, oldpm);
-	if ((PM_TYPE(oldpm->node.flags) == PM_SCALAR) &&
-	    !(pm->node.flags & PM_HASHELEM) &&
-	    (oldpm->node.flags & PM_NAMEDDIR) &&
-	    oldpm->gsu.s == &stdscalar_gsu)
-	    adduserdir(oldpm->node.nam, oldpm->u.str, 0, 0);
 	if (oldpm->node.flags & PM_EXPORTED) {
 	    /*
 	     * Re-export the old value which we removed in typeset_single().
@@ -4061,7 +4056,7 @@ strsetfn(Param pm, char *x)
 {
     zsfree(pm->u.str);
     pm->u.str = x;
-    if (!(pm->node.flags & PM_HASHELEM) &&
+    if (!(pm->node.flags & PM_HASHELEM) && !pm->level &&
 	((pm->node.flags & PM_NAMEDDIR) || isset(AUTONAMEDIRS))) {
 	pm->node.flags |= PM_NAMEDDIR;
 	adduserdir(pm->node.nam, x, 0, 0);
diff --git a/Src/utils.c b/Src/utils.c
index a1d7c8cc2..eb48e2b0f 100644
--- a/Src/utils.c
+++ b/Src/utils.c
@@ -1257,7 +1257,7 @@ getnameddir(char *name)
     /* Check if there is a scalar parameter with this name whose value *
      * begins with a `/'.  If there is, add it to the hash table and   *
      * return the new value.                                           */
-    if ((pm = (Param) paramtab->getnode(paramtab, name)) &&
+    if ((pm = (Param) paramtab->getnode(paramtab, name)) && !pm->level &&
 	    (PM_TYPE(pm->node.flags) == PM_SCALAR) &&
 	    (str = getsparam(name)) && *str == '/') {
 	pm->node.flags |= PM_NAMEDDIR;


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