Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 5/5] bashcompinit: improve compgen -F argument passing
- X-seq: zsh-workers 30134
- From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 5/5] bashcompinit: improve compgen -F argument passing
- Date: Sat, 28 Jan 2012 18:55:51 +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=nFxL+aEm7RbgHFP86ApOttOj3w4pVW7vcECuGBn4t+w=; b=n2SIHG47d+K1Gk4ZuBtHeHfXlrqxdEiNgPhgFy1IeqU4biKNBJcKPA7XldiUutX96P nX5QdC2KbyVhromhqN/UL5ghUKdeL31AB3V/suNEoPpi91ovvZn7C1+v4Wwq1ipPvpry vtU5SYuoNWZ0NolCE96Mu94WfcJMojWFbOhVg=
- 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>
Otherwise something like
% compgen -F _foo -- fi
Would not pass the arguments ('fi') to the function, like bash does.
I looked that the source code of bash, and they pass only the first
extra argument as argv $2. Let's do the same.
This is not a big deal, as 'compgen -F' would match the results, instead
of 'compgen -W' like in bash, but the end result is the same. Same as if
zsh's matching (compadd) is used instead.
Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
Completion/bashcompinit | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/Completion/bashcompinit b/Completion/bashcompinit
index 9c561c5..31f64f8 100644
--- a/Completion/bashcompinit
+++ b/Completion/bashcompinit
@@ -18,7 +18,7 @@ _bash_complete() {
[[ ${argv[${argv[(I)nospace]:-0}-1]} = -o ]] && suf=( -S '' )
- matches=( ${(f)"$(compgen $@)"} )
+ matches=( ${(f)"$(compgen $@ ${words[CURRENT]})"} )
if [[ -n $matches ]]; then
if [[ ${argv[${argv[(I)filenames]:-0}-1]} = -o ]]; then
@@ -121,12 +121,13 @@ compgen() {
;;
F)
COMPREPLY=()
+ local -a args
+ args=( "${words[0]}" "${@[-1]}" "${words[CURRENT-2]}" )
(){
- set -- "${words[0]}" "${words[CURRENT-1]}" "${words[CURRENT-2]}"
# There may be more things we need to add to this typeset to
# protect bash functions from compsys special variable names
typeset -h words
- $OPTARG "$@"
+ $OPTARG "${args[@]}"
}
results+=( "${COMPREPLY[@]}" )
;;
--
1.7.8.3
Messages sorted by:
Reverse Date,
Date,
Thread,
Author