From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19388 invoked by alias); 28 Jan 2012 16:56:41 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 30134 Received: (qmail 24097 invoked from network); 28 Jan 2012 16:56:40 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,NML_ADSP_CUSTOM_MED,RCVD_IN_DNSWL_LOW, T_DKIM_INVALID,T_TO_NO_BRKTS_FREEMAIL autolearn=no version=3.3.2 Received-SPF: pass (ns1.primenet.com.au: SPF record at _spf.google.com designates 209.85.215.43 as permitted sender) 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= From: Felipe Contreras To: zsh-workers@zsh.org Cc: Felipe Contreras Subject: [PATCH 5/5] bashcompinit: improve compgen -F argument passing Date: Sat, 28 Jan 2012 18:55:51 +0200 Message-Id: <1327769751-6806-6-git-send-email-felipe.contreras@gmail.com> X-Mailer: git-send-email 1.7.8.3 In-Reply-To: <1327769751-6806-1-git-send-email-felipe.contreras@gmail.com> 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 --- 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