Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH 1/5] bashcompinit: remove _compgen_opt_words



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