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

PATCH: globalexport option



This implements the option that differentiates between the old kludge for
turning on -g with typeset -x and the more natural code which doesn't.

There's also a patch for Etc/MACHINES to note that OpenBSD works.

Index: Doc/Zsh/builtins.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/builtins.yo,v
retrieving revision 1.3
diff -u -r1.3 builtins.yo
--- Doc/Zsh/builtins.yo	2000/04/13 14:22:47	1.3
+++ Doc/Zsh/builtins.yo	2000/04/16 18:26:52
@@ -1160,9 +1160,10 @@
 )
 item(tt(-x))(
 Mark for automatic export to the environment of subsequently
-executed commands.  Currently this implies the option tt(-g), unless tt(+g)
-is also explicitly given, in other words the parameter is not made local to
-the enclosing function.  This is for compatibility with other shells.
+executed commands.  If the option tt(GLOBAL_EXPORT) is set, this implies
+the option tt(-g), unless tt(+g) is also explicitly given; in other words
+the parameter is not made local to the enclosing function.  This is for
+compatibility with previous versions of zsh.
 )
 enditem()
 )
Index: Doc/Zsh/options.yo
===================================================================
RCS file: /cvsroot/zsh/zsh/Doc/Zsh/options.yo,v
retrieving revision 1.1.1.30
diff -u -r1.1.1.30 options.yo
--- Doc/Zsh/options.yo	2000/02/09 18:58:23	1.1.1.30
+++ Doc/Zsh/options.yo	2000/04/16 18:26:55
@@ -381,6 +381,24 @@
 Perform filename generation (globbing).
 (See noderef(Filename Generation).)
 )
+pindex(GLOBAL_EXPORT)
+cindex(environment, and local parameters)
+item(tt(GLOBAL_EXPORT) (tt<Z>))(
+If this option is set, passing the tt(-x) flag to the builtins tt(declare),
+tt(float), tt(integer), tt(readonly) and tt(typeset) (but not tt(local))
+will also set the tt(-g) flag;  hence parameters exported to
+the environment will not be made local to the enclosing function, unless
+they were already or the flag tt(+g) is given explicitly.  If the option is
+unset, exported parameters will be made local in just the same way as any
+other parameter.
+
+This option is set by default for backward compatibility; it is not
+recommended that its behaviour be relied upon.  Note that the builtin
+tt(export) always sets both the tt(-x) and tt(-g) flags, and hence its
+effect extends beyond the scope of the enclosing function; this is the
+most portable way to achieve this behaviour.
+)
+cindex(exporting, and local parameters)
 pindex(GLOBAL_RCS)
 cindex(startup files, global, inhibiting)
 cindex(files, global startup, inhibiting)
Index: Etc/MACHINES
===================================================================
RCS file: /cvsroot/zsh/zsh/Etc/MACHINES,v
retrieving revision 1.1.1.11
diff -u -r1.1.1.11 MACHINES
--- Etc/MACHINES	2000/03/25 00:21:56	1.1.1.11
+++ Etc/MACHINES	2000/04/16 18:26:55
@@ -98,6 +98,9 @@
 	Should build `out-of-the-box', but the zsh malloc routines are
 	not recommended.
 
+OpenBSD: OpenBSD 2.6
+	Should build `out-of-the-box'.
+
 SIEMENS: Reliant UNIX
        Builds `out-of-the-box'. Dynamic loading is supported. 
        Large Files and 64-bit integers are supported as of version 5.44
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.7
diff -u -r1.7 builtin.c
--- Src/builtin.c	2000/04/13 14:22:47	1.7
+++ Src/builtin.c	2000/04/16 18:27:10
@@ -1850,7 +1850,8 @@
 	return 0;
     }
 
-    if ((!ops['g'] && !ops['x']) || ops['g'] == 2 || *name == 'l')
+    if ((!ops['g'] && !ops['x']) || ops['g'] == 2 || *name == 'l' ||
+	!isset(GLOBALEXPORT))
 	on |= PM_LOCAL;
 
     if (on & PM_TIED) {
Index: Src/options.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/options.c,v
retrieving revision 1.1.1.21
diff -u -r1.1.1.21 options.c
--- Src/options.c	2000/02/09 01:15:29	1.1.1.21
+++ Src/options.c	2000/04/16 18:27:14
@@ -112,6 +112,7 @@
 {NULL, "flowcontrol",	      OPT_ALL,			 FLOWCONTROL},
 {NULL, "functionargzero",     OPT_EMULATE|OPT_NONBOURNE, FUNCTIONARGZERO},
 {NULL, "glob",		      OPT_EMULATE|OPT_ALL,	 GLOBOPT},
+{NULL, "globalexport",        OPT_EMULATE|OPT_ZSH,	 GLOBALEXPORT},
 {NULL, "globalrcs",           OPT_ALL,			 GLOBALRCS},
 {NULL, "globassign",	      OPT_EMULATE|OPT_CSH,	 GLOBASSIGN},
 {NULL, "globcomplete",	      0,			 GLOBCOMPLETE},
Index: Src/zsh.h
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/zsh.h,v
retrieving revision 1.6
diff -u -r1.6 zsh.h
--- Src/zsh.h	2000/04/14 11:49:32	1.6
+++ Src/zsh.h	2000/04/16 18:27:20
@@ -1344,6 +1344,7 @@
     EXTENDEDHISTORY,
     FLOWCONTROL,
     FUNCTIONARGZERO,
+    GLOBALEXPORT,
     GLOBALRCS,
     GLOBOPT,
     GLOBASSIGN,

-- 
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxx>
Work: pws@xxxxxxxxxxxxxxxxxxxxxxxxx
Web: http://www.pwstephenson.fsnet.co.uk



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