From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16706 invoked by alias); 28 Jan 2012 16:56:34 -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: 30131 Received: (qmail 10360 invoked from network); 28 Jan 2012 16:56:32 -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=Z8baQt8EF5r4tWF4PkQe2F1KZ9m9m3qIsM9ge11wF5E=; b=EllhJnPZlyQwbfWQ4FjKRHDkoYvVgYabnQ4fTDcFB/HUHkBLd+toVauP4ymhxZtSE8 lIxy6NGpEuVXRW3YRkuuhxMwMoY5PQjfGTqHSsWvzdbvw7u0oiKQXC2cAq5breOOfQkl fKU6JMCW0CiY77TUhk05Sv47OIQKubyZHI4hc= From: Felipe Contreras To: zsh-workers@zsh.org Cc: Felipe Contreras , Rocky Bernstein , Peter Stephenson Subject: [PATCH 1/5] bashcompinit: remove _compgen_opt_words Date: Sat, 28 Jan 2012 18:55:47 +0200 Message-Id: <1327769751-6806-2-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> There's already code for this[1]: support for the last, `word' option to compgen. Zsh's matching does a better job but if you need to, comment this in and use compadd -U So either we rely on zsh's matching (compadd), or we enable this code unconditionally so compgen works the same as in bash--and use compadd -U. This kinds of reverts 2e25dfb[2], except that the original code: eval "results+=( $OPTARG )" was wrong; it would fail if IFS is different. The new code has 'words=( ${~=1} )', which is corrent, and I transalted that to 'results+=( ${~=OPTARG} )', so there should not be any regression. The original report for 2e25dfb[2] explained this is the desired behavior. $ compgen -W 'abc abe ab a def' ab abc abe ab If the code in [1] is enabled, I get _exactly_ the same result. [1] (( $# )) && results=( "${(M)results[@]:#$1*}" ) [2] Rocky Bernstein: 29135 (plus tweaks): compgen -W in bash completion Cc: Rocky Bernstein Cc: Peter Stephenson Signed-off-by: Felipe Contreras --- Completion/bashcompinit | 9 +-------- 1 files changed, 1 insertions(+), 8 deletions(-) diff --git a/Completion/bashcompinit b/Completion/bashcompinit index 63101a9..01cc38b 100644 --- a/Completion/bashcompinit +++ b/Completion/bashcompinit @@ -41,13 +41,6 @@ _bash_complete() { return ret } -_compgen_opt_words() { - typeset -a words - words=( ${~=1} ) - local find="$2" - results=(${(M)words[@]:#$find*}) -} - compgen() { local opts prefix suffix job OPTARG OPTIND ret=1 local -a name res results jids @@ -141,7 +134,7 @@ compgen() { results+=( ${~OPTARG} ) unsetopt nullglob ;; - W) _compgen_opt_words "$OPTARG" "${@[-1]}" ;; + W) results+=( ${~=OPTARG} ) ;; C) results+=( $(eval $OPTARG) ) ;; P) prefix="$OPTARG" ;; S) suffix="$OPTARG" ;; -- 1.7.8.3