summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-05-29 11:59:50 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-05-29 11:59:50 +0000
commit4a7abbfdd6c68616143bae840333adeed5ad0066 (patch)
tree2bc3f4bf439c78ee7e1135361bc86d2d708c0125 /Completion
parent1bb5d5aeb5565215aa3359874d7701045926b1b7 (diff)
downloadzsh-4a7abbfdd6c68616143bae840333adeed5ad0066.tar.gz
zsh-4a7abbfdd6c68616143bae840333adeed5ad0066.tar.xz
zsh-4a7abbfdd6c68616143bae840333adeed5ad0066.zip
use `eval $_comp_setup' in all entry points of the completion system to not only set up the options, but also redirect stdin and ignore trap handlers for ZERR (14530)
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Base/Completer/_expand_alias2
-rw-r--r--Completion/Base/Core/_main_complete7
-rw-r--r--Completion/Base/Widget/_bash_completions2
-rw-r--r--Completion/Base/Widget/_complete_debug4
-rw-r--r--Completion/Base/Widget/_complete_help4
-rw-r--r--Completion/Base/Widget/_correct_word2
-rw-r--r--Completion/Base/Widget/_expand_word2
-rw-r--r--Completion/Base/Widget/_history_complete_word2
-rw-r--r--Completion/Base/Widget/_next_tags2
-rw-r--r--Completion/compinit11
10 files changed, 20 insertions, 18 deletions
diff --git a/Completion/Base/Completer/_expand_alias b/Completion/Base/Completer/_expand_alias
index 3809a834f..e711338a8 100644
--- a/Completion/Base/Completer/_expand_alias
+++ b/Completion/Base/Completer/_expand_alias
@@ -2,7 +2,7 @@
 
 local word expl tmp pre sel what
 
-setopt localoptions ${_comp_options[@]}
+eval "$_comp_setup"
 
 if [[ -n $funcstack[2] ]]; then
   if [[ "$funcstack[2]" = _prefix ]]; then
diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete
index f38354815..eecb30b34 100644
--- a/Completion/Base/Core/_main_complete
+++ b/Completion/Base/Core/_main_complete
@@ -16,12 +16,7 @@
 # which makes the output of setopt and unsetopt reflect a different
 # state than the global one for which you are completing.
 
-setopt localoptions ${_comp_options[@]}
-
-exec </dev/null	# ZLE closes stdin, which can cause errors
-
-# Failed returns from this code are not real errors
-setopt localtraps noerrexit ; trap - ZERR
+eval "$_comp_setup"
 
 local func funcs ret=1 tmp _compskip format nm call match min max i num\
       _completers _completer _completer_num curtag _comp_force_list \
diff --git a/Completion/Base/Widget/_bash_completions b/Completion/Base/Widget/_bash_completions
index 6980e8bfd..7abb654d4 100644
--- a/Completion/Base/Widget/_bash_completions
+++ b/Completion/Base/Widget/_bash_completions
@@ -25,7 +25,7 @@
 # that will not have been overridden, so you should add '~' to the
 # list of keys at the top of the for-loop.
 
-setopt localoptions ${_comp_options[@]}
+eval "$_comp_setup"
 
 local key=$KEYS[-1] expl
 
diff --git a/Completion/Base/Widget/_complete_debug b/Completion/Base/Widget/_complete_debug
index acdb48fd8..6f670c8a9 100644
--- a/Completion/Base/Widget/_complete_debug
+++ b/Completion/Base/Widget/_complete_debug
@@ -1,8 +1,6 @@
 #compdef -k complete-word \C-x?
 
-setopt localoptions ${_comp_options[@]}
-
-setopt localtraps noerrexit ; trap - ZERR
+eval "$_comp_setup"
 
 (( $+_debug_count )) || integer -g _debug_count
 local tmp=${TMPPREFIX}${$}${words[1]:t}$[++_debug_count]
diff --git a/Completion/Base/Widget/_complete_help b/Completion/Base/Widget/_complete_help
index bfbfa3222..ffbcf0caa 100644
--- a/Completion/Base/Widget/_complete_help
+++ b/Completion/Base/Widget/_complete_help
@@ -1,9 +1,7 @@
 #compdef -k complete-word \C-xh
 
 _complete_help() {
-  setopt localoptions ${_comp_options[@]}
-
-  exec </dev/null	# ZLE closes stdin, which can cause errors
+  eval "$_comp_setup"
 
   local _sort_tags=_help_sort_tags text i j k tmp
   typeset -A help_funcs help_tags help_sfuncs help_styles
diff --git a/Completion/Base/Widget/_correct_word b/Completion/Base/Widget/_correct_word
index 11b37efb1..fe2fbfeb1 100644
--- a/Completion/Base/Widget/_correct_word
+++ b/Completion/Base/Widget/_correct_word
@@ -7,7 +7,7 @@
 # If configurations keys with the prefix `correctword_' are
 # given they override those starting with `correct_'.
 
-setopt localoptions ${_comp_options[@]}
+eval "$_comp_setup"
 
 local curcontext="$curcontext"
 
diff --git a/Completion/Base/Widget/_expand_word b/Completion/Base/Widget/_expand_word
index 48ce87ede..1e8ddb21b 100644
--- a/Completion/Base/Widget/_expand_word
+++ b/Completion/Base/Widget/_expand_word
@@ -2,7 +2,7 @@
 
 # Simple completion front-end implementing expansion.
 
-setopt localoptions ${_comp_options[@]}
+eval "$_comp_setup"
 
 local curcontext="$curcontext"
 
diff --git a/Completion/Base/Widget/_history_complete_word b/Completion/Base/Widget/_history_complete_word
index 1142f2f91..fe2a846db 100644
--- a/Completion/Base/Widget/_history_complete_word
+++ b/Completion/Base/Widget/_history_complete_word
@@ -15,7 +15,7 @@
 #   range -- range of history words to complete
 
 _history_complete_word () {
-  setopt localoptions ${_comp_options[@]}
+  eval "$_comp_setup"
 
   local expl direction stop curcontext="$curcontext"
 
diff --git a/Completion/Base/Widget/_next_tags b/Completion/Base/Widget/_next_tags
index 29196a14d..0620a1f99 100644
--- a/Completion/Base/Widget/_next_tags
+++ b/Completion/Base/Widget/_next_tags
@@ -3,7 +3,7 @@
 # Main widget.
 
 _next_tags() {
-  setopt localoptions ${_comp_options[@]}
+  eval "$_comp_setup"
 
   local ins ops="$PREFIX$SUFFIX"
 
diff --git a/Completion/compinit b/Completion/compinit
index 05ef2c379..4b85be764 100644
--- a/Completion/compinit
+++ b/Completion/compinit
@@ -139,8 +139,19 @@ _comp_options=(
     NO_cshnullglob
     NO_allexport
     NO_aliases
+    NO_errexit
 )
 
+# And this one should be `eval'ed at the beginning of every entry point
+# to the completion system.  It sets up what we currently consider a
+# sane environment.  That means we set the options above, make sure we
+# have a valid stdin descriptor (zle closes it before calling widgets)
+# and don't get confused by user's ZERR trap handlers.
+
+_comp_setup='setopt localoptions localtraps ${_comp_options[@]};
+             exec </dev/null;
+             trap - ZERR'
+
 # These can hold names of functions that are to be called before/after all
 # matches have been generated.