zsh-workers
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: zsh-workers@zsh.org
Subject: Bug with bash completion emulation
Date: Wed, 25 Jan 2012 02:43:40 +0200	[thread overview]
Message-ID: <CAMP44s10+qonQNj9v6gqdy+96giPcndT+Xwd7nm1S=id83p=6w@mail.gmail.com> (raw)

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


                 reply	other threads:[~2012-01-25  0:50 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAMP44s10+qonQNj9v6gqdy+96giPcndT+Xwd7nm1S=id83p=6w@mail.gmail.com' \
    --to=felipe.contreras@gmail.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).