about summary refs log tree commit diff
path: root/Src/builtin.c
diff options
context:
space:
mode:
authorBarton E. Schaefer <schaefer@zsh.org>2016-10-29 11:56:50 -0700
committerBarton E. Schaefer <schaefer@zsh.org>2016-10-29 11:56:50 -0700
commitab81b98c49ace618f5a1607faf718e0b2e43948d (patch)
tree176def1f3a76e94c0b8d6821e410f702b571e373 /Src/builtin.c
parent87c951c6bd5f889ec849ea45353969b407f8d5d5 (diff)
downloadzsh-ab81b98c49ace618f5a1607faf718e0b2e43948d.tar.gz
zsh-ab81b98c49ace618f5a1607faf718e0b2e43948d.tar.xz
zsh-ab81b98c49ace618f5a1607faf718e0b2e43948d.zip
39758: revise 39704 for array and hash parameters; more POSIXBUITINS tweaks for
export

39704 was commit 0f5e670, forgot to reference article number in that log.

"typeset -p" outputs "typeset" for array and hash parameters, even when
exported, because those types can be marked export but are never pushed
to the enviroment.

For POSIXBUILTINS, "export var" does not implicitly set $var, and its
export state is preserved when assigned (but not when explicitly unset).
Diffstat (limited to 'Src/builtin.c')
-rw-r--r--Src/builtin.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/Src/builtin.c b/Src/builtin.c
index 2db739ffc..986ace238 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -2008,11 +2008,12 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
      * handled in createparam().  Here we just avoid using it for the
      * present tests if it's unset.
      *
-     * POSIXBUILTINS horror: we need to retain the 'readonly' flag
-     * of an unset parameter.
+     * POSIXBUILTINS horror: we need to retain the 'readonly' or 'export'
+     * flags of an unset parameter.
      */
     usepm = pm && (!(pm->node.flags & PM_UNSET) ||
-		   (isset(POSIXBUILTINS) && (pm->node.flags & PM_READONLY)));
+		   (isset(POSIXBUILTINS) &&
+		    (pm->node.flags & (PM_READONLY|PM_EXPORTED))));
 
     /*
      * We need to compare types with an existing pm if special,
@@ -2135,7 +2136,8 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
 	/*
 	 * Stricter rules about retaining readonly attribute in this case.
 	 */
-	if ((on & PM_READONLY) && (!usepm || (pm->node.flags & PM_UNSET)) &&
+	if ((on & (PM_READONLY|PM_EXPORTED)) &&
+	    (!usepm || (pm->node.flags & PM_UNSET)) &&
 	    !ASG_VALUEP(asg))
 	    on |= PM_UNSET;
 	else if (usepm && (pm->node.flags & PM_READONLY) &&
@@ -2143,6 +2145,10 @@ typeset_single(char *cname, char *pname, Param pm, UNUSED(int func),
 	    zerr("read-only variable: %s", pm->node.nam);
 	    return NULL;
 	}
+	/* This is handled by createparam():
+	if (usepm && (pm->node.flags & PM_EXPORTED) && !(off & PM_EXPORTED))
+	    on |= PM_EXPORTED;
+	*/
     }
 
     /*