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

PATCH: "typeset -x" acts as if "-g"



This change should make "typeset -x" completely equivalent to "export", as
it was before the "-g" option was introduced some while ago.  Note that you
still can't export a local, so neither "export FOO" nor "typeset -x FOO"
changes the environment if there's a local FOO in some surrounding scope.

I looked at lifting that restriction in sh/ksh emulation modes, but I need
to find out why the addenv() in restore_params() doesn't do what I expect.

Index: Src/builtin.c
===================================================================
@@ -1857,7 +1857,7 @@
 	return 0;
     }
 
-    if (!ops['g'])
+    if (!ops['g'] && !ops['x'])
 	on |= PM_LOCAL;
 
     if (on & PM_TIED) {
@@ -1895,7 +1895,7 @@
 	 */
 	if ((pm = (Param) paramtab->getnode(paramtab, asg0.name))
 	    && !(pm->flags & PM_UNSET)
-	    && (locallevel == pm->level || func == BIN_EXPORT)) {
+	    && (locallevel == pm->level || !(on & PM_LOCAL))) {
 	    if (!asg0.value && !(PM_TYPE(pm->flags) & (PM_ARRAY|PM_HASHED)))
 		oldval = ztrdup(getsparam(asg0.name));
 	    on |= (pm->flags & PM_EXPORTED);

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



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