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

Bug with bash completion emulation



Hi,

The following script shows a problem that happens with git's bash completion:

---
#!/bin/sh

if [[ -n ${ZSH_VERSION-} ]]; then
    autoload -U +X bashcompinit && bashcompinit
fi

_foo()
{
    local cur="${COMP_WORDS[COMP_CWORD]}"
    local IFS=$'\n'
    w[0]='first '
    w[1]='second and space '
    w[2]='third\\ quoted\\ space '
    COMPREPLY=( $(compgen -W "${w[*]}" -- $cur) )
}
complete -o nospace -F _foo foo
---

The result in bash (by typing 'foo f<tab>', 'foo s<tab>', and so on) is:

'foo first '
'foo second and space '
'foo third\ quoted\ space '

In zsh, the results are quite different:

'foo first\ '
'foo second\ and\ space\ '
'foo third\ quoted\ space\ '

The following patch improves the results for me, but I get 'foo
third\\ quoted\\ space ', which is still not correct.

Any ideas?

---
--- bashcompinit	2012-01-25 00:20:54.933054267 +0200
+++ bashcompinit	2012-01-25 02:34:24.795667889 +0200
@@ -26,7 +26,7 @@
       compset -S '/*' && matches=( ${matches%%/*} )
       compadd -f "${suf[@]}" -a matches && ret=0
     else
-      compadd "${suf[@]}" -a matches && ret=0
+      compadd -Q "${suf[@]}" -a matches && ret=0
     fi
   fi

@@ -160,7 +160,7 @@
   #shift $(( OPTIND - 1 ))
   #(( $# )) && results=( "${(M)results[@]:#$1*}" )

-  print -l -- "$prefix${^results[@]}$suffix"
+  print -l -r -- "$prefix${^results[@]}$suffix"
 }

 complete() {
---

-- 
Felipe Contreras



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