zsh-workers
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: zsh-workers@zsh.org
Cc: Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH 5/5] bashcompinit: improve compgen -F argument passing
Date: Sat, 28 Jan 2012 18:55:51 +0200	[thread overview]
Message-ID: <1327769751-6806-6-git-send-email-felipe.contreras@gmail.com> (raw)
In-Reply-To: <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@gmail.com>
---
 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


  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 ` [PATCH 3/5] bashcompinit: fix quoting code Felipe Contreras
2012-01-28 16:55 ` [PATCH 4/5] bashcompinit: simplify result matching code Felipe Contreras
2012-01-28 16:55 ` Felipe Contreras [this message]
2012-01-28 17:14   ` [PATCH 5/5] bashcompinit: improve compgen -F argument passing 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-6-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).