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

Re: [PATCH] typeset reply array



On Sun, 18 May 2008 18:17:35 +0100
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> wrote:
> Commonly used but non-global parameters such as "reply" could, and
> probably should, be made local to the top-level of completion at around
> the point where the options get set.  This would save them appearing in
> the user's own space, which was the whole point of warncreateglobal in
> the first place.
> 
> A "typeset -g" for variables that *should* be global makes perfect
> sense.  The "-g" should definitely be present even if the code isn't
> inside a function (although the compinit stuff is), since we shouldn't
> make that assumption.

This does that.  It's the same basic principle as the original patch,
but should be safe.

Index: Completion/compinit
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/compinit,v
retrieving revision 1.20
diff -u -r1.20 compinit
--- Completion/compinit	12 Apr 2008 16:32:43 -0000	1.20
+++ Completion/compinit	18 May 2008 19:23:01 -0000
@@ -118,6 +118,7 @@
 typeset -gA _lastcomp
 
 # Remember dumpfile.
+typeset -g _comp_dumpfile
 if [[ -n $_i_dumpfile ]]; then
   # Explicitly supplied dumpfile.
   _comp_dumpfile="$_i_dumpfile"
@@ -127,6 +128,7 @@
 
 # The standard options set in completion functions.
 
+typeset -ga _comp_options
 _comp_options=(
        bareglobqual
        extendedglob
@@ -158,14 +160,18 @@
 # have a valid stdin descriptor (zle closes it before calling widgets)
 # and don't get confused by user's ZERR trap handlers.
 
+typeset -g _comp_setup
 _comp_setup='setopt localoptions localtraps ${_comp_options[@]};
              local IFS=$'\'\ \\t\\r\\n\\0\''
              exec </dev/null;
-             trap - ZERR'
+             trap - ZERR
+             local -a reply
+             local REPLY'
 
 # These can hold names of functions that are to be called before/after all
 # matches have been generated.
 
+typeset -ga compprefuncs comppostfuncs
 compprefuncs=()
 comppostfuncs=()
 
 
-- 
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/



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