From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22565 invoked from network); 16 Apr 2000 18:29:10 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 16 Apr 2000 18:29:10 -0000 Received: (qmail 22029 invoked by alias); 16 Apr 2000 18:28:59 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10771 Received: (qmail 22016 invoked from network); 16 Apr 2000 18:28:58 -0000 To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Subject: PATCH: globalexport option Date: Sun, 16 Apr 2000 19:28:58 +0100 From: Peter Stephenson Message-Id: 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))( +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 Work: pws@CambridgeSiliconRadio.com Web: http://www.pwstephenson.fsnet.co.uk