diff options
Diffstat (limited to 'Completion/compinit')
| -rw-r--r-- | Completion/compinit | 58 |
1 files changed, 21 insertions, 37 deletions
diff --git a/Completion/compinit b/Completion/compinit index 60dbb599d..2d6bf554a 100644 --- a/Completion/compinit +++ b/Completion/compinit @@ -77,38 +77,16 @@ setopt extendedglob typeset _i_dumpfile _i_files _i_line _i_done _i_dir _i_autodump=1 typeset _i_tag _i_file _i_addfiles _i_fail=ask _i_check=yes _i_name _i_why -while [[ $# -gt 0 && $1 = -[dDiuCw] ]]; do - case "$1" in - -d) - _i_autodump=1 - shift - if [[ $# -gt 0 && "$1" != -[dfQC] ]]; then - _i_dumpfile="$1" - shift - fi - ;; - -D) - _i_autodump=0 - shift - ;; - -i) - _i_fail=ign - shift - ;; - -u) - _i_fail=use - shift - ;; - -C) - _i_check= - shift - ;; - -w) - _i_why=1 - shift - ;; - esac -done +# note: for historical reasons it must be possible to give the optional arg to +# -d in the next parameter. zparseopts handles this by default +local -A _i_opth +zparseopts -A _i_opth -D -F - C d:: D i u w || return +(( $+_i_opth[-C] )) && _i_check= +(( $+_i_opth[-d] )) && _i_autodump=1 _i_dumpfile=$_i_opth[-d] +(( $+_i_opth[-D] )) && _i_autodump=0 +(( $+_i_opth[-i] )) && _i_fail=ign +(( $+_i_opth[-u] )) && _i_fail=use +(( $+_i_opth[-w] )) && _i_why=1 # The associative arrays containing the definitions for the commands and # services. @@ -345,7 +323,7 @@ compdef() { [[ $2 = .menu-select ]] && zmodload -i zsh/complist zle -C "$1" "$2" "$func" if [[ -n $new ]]; then - bindkey "$3" | IFS=$' \t' read -A opt + opt=( ${(z)${ bindkey "$3" }} ) [[ $opt[-1] = undefined-key ]] && bindkey "$3" "$1" else bindkey "$3" "$1" @@ -372,8 +350,8 @@ compdef() { # And bind the keys... for i; do if [[ -n $new ]]; then - bindkey "$i" | IFS=$' \t' read -A opt - [[ $opt[-1] = undefined-key ]] || continue + opt=( ${(z)${ bindkey "$i" }} ) + [[ $opt[-1] = undefined-key ]] || continue fi bindkey "$i" "$func" done @@ -461,6 +439,7 @@ if [[ -n "$_i_check" ]]; then if ! read -q \ "?zsh compinit: insecure $_i_q, run compaudit for list. Ignore insecure $_i_q and continue [y] or abort compinit [n]? "; then + print -u2 print -u2 "$0: initialization aborted" unfunction compinit compdef unset _comp_dumpfile _comp_secure compprefuncs comppostfuncs \ @@ -468,6 +447,7 @@ Ignore insecure $_i_q and continue [y] or abort compinit [n]? "; then return 1 fi + print -u2 fi fpath=(${fpath:|_i_wdirs}) (( $#_i_wfiles )) && _i_files=( "${(@)_i_files:#(${(j:|:)_i_wfiles%.zwc})}" ) @@ -484,6 +464,8 @@ autoload -RUz compdump compinstall _i_done='' +[[ _i_why -eq 1 ]] && print -ru2 "Using dump file: $_comp_dumpfile" + if [[ -f "$_comp_dumpfile" ]]; then if [[ -n "$_i_check" ]]; then IFS=$' \t' read -rA _i_line < "$_comp_dumpfile" @@ -493,7 +475,7 @@ if [[ -f "$_comp_dumpfile" ]]; then builtin . "$_comp_dumpfile" _i_done=yes elif [[ _i_why -eq 1 ]]; then - print -nu2 "Loading dump file skipped, regenerating" + print -nu2 "Loading dump file skipped" local pre=" because: " if [[ _i_autodump -ne 1 ]]; then print -nu2 $pre"-D flag given" @@ -513,8 +495,9 @@ if [[ -f "$_comp_dumpfile" ]]; then _i_done=yes fi elif [[ _i_why -eq 1 ]]; then - print -u2 "No existing compdump file found, regenerating" + print -u2 "No existing dump file found" fi + if [[ -z "$_i_done" ]]; then typeset -A _i_test @@ -547,6 +530,7 @@ if [[ -z "$_i_done" ]]; then # If autodumping was requested, do it now. if [[ $_i_autodump = 1 ]]; then + [[ _i_why -eq 1 ]] && print -u2 "Regenerating dump file" compdump fi fi |
