Hi -
It looks like zsh's "compgen -W" (words) does not match the same behavior as bash's. For example
in bash:
$ compgen -W 'abc abe ab a def' ab
compgen -W 'abc abe ab a def' ab
abc
abe
ab
$
versus zsh 4.3.10 (and git sources):
$ autoload -Uz bashcompinit
$ bashcompinit
$ zmodload -ap zsh/parameter parameters
$ compgen -W 'abc abe ab a def' ab
abc
abe
ab
a
def
$
Attached is a patch from git sources as of May 3rd, 2011 with a new test that I believe corrects this behavior.
Since I do not consider myself a zsh language expert, the changes in Completion/bashcompinit might be shorted or
made more zsh idomatic.
For example simplicity, to match the beginning of a word, I used
[[ $try =~ "^$find" ]]
matching using == and substrings might be faster, not that I think speed is all that important here. Ditt ofo inlining a newly added _compgen_opt_words
function; but I think that makes things uglier and harder to test.