From: Felipe Contreras <felipe.contreras@gmail.com>
To: zsh-workers@zsh.org
Cc: Felipe Contreras <felipe.contreras@gmail.com>,
Rocky Bernstein <rocky@gnu.org>,
Peter Stephenson <pws@users.sourceforge.net>
Subject: [PATCH 1/5] bashcompinit: remove _compgen_opt_words
Date: Sat, 28 Jan 2012 18:55:47 +0200 [thread overview]
Message-ID: <1327769751-6806-2-git-send-email-felipe.contreras@gmail.com> (raw)
In-Reply-To: <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@gnu.org>
Cc: Peter Stephenson <pws@users.sourceforge.net>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
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
next prev 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 ` Felipe Contreras [this message]
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 ` [PATCH 5/5] bashcompinit: improve compgen -F argument passing Felipe Contreras
2012-01-28 17:14 ` 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-2-git-send-email-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=pws@users.sourceforge.net \
--cc=rocky@gnu.org \
--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).