From: Felipe Contreras <felipe.contreras@gmail.com>
To: zsh-workers@zsh.org
Cc: Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH 3/5] bashcompinit: fix quoting code
Date: Sat, 28 Jan 2012 18:55:49 +0200 [thread overview]
Message-ID: <1327769751-6806-4-git-send-email-felipe.contreras@gmail.com> (raw)
In-Reply-To: <1327769751-6806-1-git-send-email-felipe.contreras@gmail.com>
There's a mismatch between to zsh and bash's quoting:
---
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 fixes that.
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
Completion/bashcompinit | 8 ++++----
1 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Completion/bashcompinit b/Completion/bashcompinit
index 2d6743e..4b2084a 100644
--- a/Completion/bashcompinit
+++ b/Completion/bashcompinit
@@ -24,9 +24,9 @@ _bash_complete() {
if [[ ${argv[${argv[(I)filenames]:-0}-1]} = -o ]]; then
compset -P '*/' && matches=( ${matches##*/} )
compset -S '/*' && matches=( ${matches%%/*} )
- compadd -f "${suf[@]}" -a matches && ret=0
+ compadd -Q -f "${suf[@]}" -a matches && ret=0
else
- compadd "${suf[@]}" -a matches && ret=0
+ compadd -Q "${suf[@]}" -a matches && ret=0
fi
fi
@@ -135,7 +135,7 @@ compgen() {
results+=( ${~OPTARG} )
unsetopt nullglob
;;
- W) results+=( ${~=OPTARG} ) ;;
+ W) results+=( ${(Q)~=OPTARG} ) ;;
C) results+=( $(eval $OPTARG) ) ;;
P) prefix="$OPTARG" ;;
S) suffix="$OPTARG" ;;
@@ -154,7 +154,7 @@ compgen() {
#shift $(( OPTIND - 1 ))
#(( $# )) && results=( "${(M)results[@]:#$1*}" )
- print -l -- "$prefix${^results[@]}$suffix"
+ print -l -r -- "$prefix${^results[@]}$suffix"
}
complete() {
--
1.7.8.3
next prev parent reply other threads:[~2012-01-28 16:56 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-28 16:55 [PATCH 0/5] bashcompinit: several fixes Felipe Contreras
2012-01-28 16:55 ` [PATCH 1/5] bashcompinit: remove _compgen_opt_words Felipe Contreras
2012-01-28 16:55 ` [PATCH 2/5] bashcompinit: fix COMP_POINT Felipe Contreras
2012-01-28 16:55 ` Felipe Contreras [this message]
2012-01-28 16:55 ` [PATCH 4/5] bashcompinit: simplify result matching code Felipe Contreras
2012-01-28 16:55 ` [PATCH 5/5] bashcompinit: improve compgen -F argument passing Felipe Contreras
2012-01-28 17:14 ` Felipe Contreras
2012-01-29 18:25 ` [PATCH 0/5] bashcompinit: several fixes Peter Stephenson
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=1327769751-6806-4-git-send-email-felipe.contreras@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).