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

PATCH: Handling of interrupt in completion widgets



If _complete_help or _complete_debug is interrupted, they leave the shell
in a bad state.  This patch uses traps to restore state properly.

diff -x CVS -ru ../zsh-forge/current/Completion/Base/Widget/_complete_debug Completion/Base/Widget/_complete_debug
--- ../zsh-forge/current/Completion/Base/Widget/_complete_debug	Tue May 29 08:44:07 2001
+++ Completion/Base/Widget/_complete_debug	Wed Jun 13 09:12:43 2001
@@ -7,7 +7,7 @@
 local w="${(qq)words}"
 
 exec 3>&-	# Too bad if somebody else is using it ...
-[[ -t 2 ]] && exec 3>&2 2>| $tmp
+[[ -t 2 ]] && { exec 3>&2 2>| $tmp ; trap 'exec 2>&3 3>&-' EXIT INT }
 
 setopt xtrace
 _main_complete
@@ -19,7 +19,6 @@
     _message -r "Trace output left in $tmp (up-history to view)"
     [[ $compstate[nmatches] -le 1 && $compstate[list] != *force* ]] &&
         compstate[list]='list force messages'
-    exec 2>&3 3>&-
 }
 
 return ret
diff -x CVS -ru ../zsh-forge/current/Completion/Base/Widget/_complete_help Completion/Base/Widget/_complete_help
--- ../zsh-forge/current/Completion/Base/Widget/_complete_help	Tue May 29 08:44:07 2001
+++ Completion/Base/Widget/_complete_help	Wed Jun 13 09:11:06 2001
@@ -35,10 +35,12 @@
       builtin zstyle "$@"
     fi
   }
+  trap 'unfunction compadd zstyle' EXIT INT
 
   _main_complete
 
   unfunction compadd zstyle
+  trap - EXIT INT
 
   for i in "${(@ok)help_funcs}"; do
     text="${text}

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

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   



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