Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 3/5] bashcompinit: fix quoting code
- X-seq: zsh-workers 30136
- From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 3/5] bashcompinit: fix quoting code
- Date: Sat, 28 Jan 2012 18:55:49 +0200
- Cc: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=MatCN1JPaoMSd09Y1TzTKF97OmxeedP1vJ3ERmU2bTc=; b=F9iavfKpVdwneuQxQC5POzGyapGif3IrivFMWUWmbpf9eoHzQQGsLSVsnTPHET1cQX lLyRffJyLGJpdZrQR6PndEZmQCvZVPRm7MpTsKwVr/jnjyaqrlUymcOYEZQpWkoVamtM 28i0174aZAJEWdzruIN6NwQCcRXholMdAR1pk=
- In-reply-to: <1327769751-6806-1-git-send-email-felipe.contreras@gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <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@xxxxxxxxx>
---
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author