Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
[PATCH 1/5] bashcompinit: remove _compgen_opt_words
- X-seq: zsh-workers 30131
- From: Felipe Contreras <felipe.contreras@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: [PATCH 1/5] bashcompinit: remove _compgen_opt_words
- Date: Sat, 28 Jan 2012 18:55:47 +0200
- Cc: Felipe Contreras <felipe.contreras@xxxxxxxxx>, Rocky Bernstein <rocky@xxxxxxx>, Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxx>
- 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=
- 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 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 <rocky@xxxxxxx>
Cc: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author