From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6313 invoked by alias); 30 Apr 2012 14:37:57 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 17051 Received: (qmail 16661 invoked from network); 30 Apr 2012 14:37:54 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 Received-SPF: none (ns1.primenet.com.au: domain at closedmail.com does not designate permitted sender hosts) From: Bart Schaefer Message-id: <120430073725.ZM9968@torch.brasslantern.com> Date: Mon, 30 Apr 2012 07:37:25 -0700 In-reply-to: <-840557096841281898@unknownmsgid> Comments: In reply to TJ Luoma "Re: compinit causes completion to fail?" (Apr 30, 1:04am) References: <11E3E5A7F06F49C2B05AD5289019FC72@gmail.com> <120429172415.ZM8837@torch.brasslantern.com> <-840557096841281898@unknownmsgid> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: "zsh-users@zsh.org" Subject: Re: compinit causes completion to fail? MIME-version: 1.0 Content-type: text/plain; charset=us-ascii On Apr 30, 1:04am, TJ Luoma wrote: } } So it went like this: } } * uncomment last file-to-source from within .zshenv } * start a new shell } * test to see if command and 'cd' completion worked } * exit shell (deleting ~/.zcompdump) } } * uncomment last-1 file-to-source from within .zshenv } * start a new shell } * test to see if command and 'cd' completion worked } * exit shell (deleting ~/.zcompdump) } } and so on. Future hint: Uncomment half the lines, then try. If it works, leave those uncommented and uncomment half the remaining lines. If it fails, re-comment half way back to the last place it succeeded. Repeat. (Binary search usually takes fewer comparisons than linear search.) } Everything worked fine UNTIL I put the IFS line in at the top of the } .zshenv. When I did that, completion broke. When I took it out, } completion worked. Did some quick comparison of the output of "setopt xtrace" with IFS=$'\n' vs. the default. I wrote: > IFS shouldn't affect parsing of scripts etc., it should only affect > "read" and parameter substitution. Turns out compinit uses "read" to parse #compdef lines while walking $fpath. When IFS=$'\n' the entire line is in the first element of the array, so compdef is run with the wrong arguments. Then compdef itself uses "read" to parse bindkey output, etc. I'm not sure if it's worthwhile to fix this as having IFS=$'\n' during a whole interactive shell session is likely to cause all sorts of havoc, but here's a patch anyway. Index: Completion/compinit =================================================================== retrieving revision 1.19 diff -u -r1.19 compinit --- Completion/compinit 20 Dec 2011 17:13:37 -0000 1.19 +++ Completion/compinit 30 Apr 2012 14:28:21 -0000 @@ -326,7 +326,7 @@ [[ $2 = .menu-select ]] && zmodload -i zsh/complist zle -C "$1" "$2" "$func" if [[ -n $new ]]; then - bindkey "$3" | read -A opt + bindkey "$3" | IFS=$' \t' read -A opt [[ $opt[-1] = undefined-key ]] && bindkey "$3" "$1" else bindkey "$3" "$1" @@ -353,7 +353,7 @@ # And bind the keys... for i; do if [[ -n $new ]]; then - bindkey "$i" | read -A opt + bindkey "$i" | IFS=$' \t' read -A opt [[ $opt[-1] = undefined-key ]] || continue fi bindkey "$i" "$func" @@ -469,7 +469,7 @@ if [[ -f "$_comp_dumpfile" ]]; then if [[ -n "$_i_check" ]]; then - read -rA _i_line < "$_comp_dumpfile" + IFS=$' \t' read -rA _i_line < "$_comp_dumpfile" if [[ _i_autodump -eq 1 && $_i_line[2] -eq $#_i_files && $ZSH_VERSION = $_i_line[4] ]] then @@ -491,7 +491,7 @@ _i_name="${_i_file:t}" (( $+_i_test[$_i_name] + $_i_wfiles[(I)$_i_file] )) && continue _i_test[$_i_name]=yes - read -rA _i_line < $_i_file + IFS=$' \t' read -rA _i_line < $_i_file _i_tag=$_i_line[1] shift _i_line case $_i_tag in @@ -527,7 +527,7 @@ # If the default completer set includes _expand, and tab is bound # to expand-or-complete, rebind it to complete-word instead. -bindkey '^i' | read -A _i_line +bindkey '^i' | IFS=$' \t' read -A _i_line if [[ ${_i_line[2]} = expand-or-complete ]] && zstyle -a ':completion:' completer _i_line && (( ${_i_line[(i)_expand]} <= ${#_i_line} )); then -- Barton E. Schaefer