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

[PATCH] compinit forks less



This patch to use non-forking command substitution with a here-string
to analyze `bindkey`.  I've been using it a while with no trouble.

Admittedly, a new zsh/zparameter $bindkeys associative array would be
nicer still to introspect key bindings (rather than parsing piped
builtin output).  That's also more work and the way of this patch
also helps show the new non-forking command substitution if there is
interest in doing that.
diff --git a/Completion/compinit b/Completion/compinit
index 2bfd30f2e..c904dc6ef 100644
--- a/Completion/compinit
+++ b/Completion/compinit
@@ -344,7 +344,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
+	  IFS=$' \t' read -A opt <<< ${ bindkey "$3" }
 	  [[ $opt[-1] = undefined-key ]] && bindkey "$3" "$1"
 	else
 	  bindkey "$3" "$1"
@@ -371,7 +371,7 @@ compdef() {
       # And bind the keys...
       for i; do
         if [[ -n $new ]]; then
-	   bindkey "$i" | IFS=$' \t' read -A opt
+	   IFS=$' \t' read -A opt <<< ${ bindkey "$i" }
 	   [[ $opt[-1] = undefined-key ]] || continue
 	fi
         bindkey "$i" "$func"
@@ -560,7 +560,7 @@ zle -la menu-select && zle -C menu-select .menu-select _main_complete
 
 # If the default completer set includes _expand, and tab is bound
 # to expand-or-complete, rebind it to complete-word instead.
-bindkey '^i' | IFS=$' \t' read -A _i_line
+IFS=$' \t' read -A _i_line <<< ${ bindkey '^i' }
 if [[ ${_i_line[2]} = expand-or-complete ]] &&
   zstyle -a ':completion:' completer _i_line &&
   (( ${_i_line[(i)_expand]} <= ${#_i_line} )); then


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