about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/builtin.c3
-rw-r--r--Src/params.c9
-rw-r--r--Src/zsh.h1
3 files changed, 9 insertions, 4 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index dd0d3e523..73d89aa4f 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -1630,7 +1630,8 @@ typeset_single(char *cname, char *pname, Param pm, int func,
 		if (!(pm->flags & PM_UNSET) && !pm->env && !value)
 		    pm->env = addenv(pname, getsparam(pname), pm->flags);
 	    } else if (pm->env &&
-		       (!pm->level || (isset(ALLEXPORT) && !pm->old))) {
+		       (!pm->level || (isset(ALLEXPORT) && !pm->old &&
+				       !(pm->flags & PM_HASHELEM)))) {
 		delenv(pm->env);
 		zsfree(pm->env);
 		pm->env = NULL;
diff --git a/Src/params.c b/Src/params.c
index a7444bfd1..3179fc6a7 100644
--- a/Src/params.c
+++ b/Src/params.c
@@ -617,6 +617,9 @@ createparam(char *name, int flags)
 {
     Param pm, oldpm;
 
+    if (paramtab != realparamtab)
+	flags = (flags & ~PM_EXPORTED) | PM_HASHELEM;
+
     if (name != nulstring) {
 	oldpm = (Param) (paramtab == realparamtab ?
 			 gethashnode2(paramtab, name) :
@@ -646,7 +649,7 @@ createparam(char *name, int flags)
 	    paramtab->addnode(paramtab, ztrdup(name), pm);
 	}
 
-	if (isset(ALLEXPORT) && !oldpm)
+	if (isset(ALLEXPORT) && !oldpm && !(flags & PM_HASHELEM))
 	    flags |= PM_EXPORTED;
     } else {
 	pm = (Param) zhalloc(sizeof *pm);
@@ -1520,7 +1523,7 @@ setstrvalue(Value v, char *val)
 	break;
     }
     if ((!v->pm->env && !(v->pm->flags & PM_EXPORTED) &&
-	 !(isset(ALLEXPORT) && !v->pm->old)) ||
+	 !(isset(ALLEXPORT) && !v->pm->old && !(v->pm->flags & PM_HASHELEM))) ||
 	(v->pm->flags & PM_ARRAY) || v->pm->ename)
 	return;
     if (PM_TYPE(v->pm->flags) == PM_INTEGER)
@@ -2742,7 +2745,7 @@ arrfixenv(char *s, char **t)
      */
     if (t == path)
 	cmdnamtab->emptytable(cmdnamtab);
-    if (isset(ALLEXPORT) ? !!pm->old : pm->level)
+    if ((pm->flags & PM_HASHELEM) || (isset(ALLEXPORT) ? !!pm->old : pm->level))
 	return;
     u = t ? zjoin(t, ':', 1) : "";
     len_s = strlen(s);
diff --git a/Src/zsh.h b/Src/zsh.h
index 35b9c6737..6c5c9122d 100644
--- a/Src/zsh.h
+++ b/Src/zsh.h
@@ -1125,6 +1125,7 @@ struct param {
 #define PM_REMOVABLE	(1<<21)	/* special can be removed from paramtab     */
 #define PM_AUTOLOAD	(1<<22) /* autoloaded from module                   */
 #define PM_NORESTORE	(1<<23)	/* do not restore value of local special    */
+#define PM_HASHELEM     (1<<24) /* is a hash-element */
 
 /* The option string corresponds to the first of the variables above */
 #define TYPESET_OPTSTR "aiEFALRZlurtxUhT"