compgen on zsh returns a different result than on bash

I am trying to make bash completions work properly in zsh.

I am aware of the need to load these in ~/.zshrc:

autoload -Uz +X compinit && compinit
autoload -Uz +X bashcompinit && bashcompinit

One thing I observed, is that the compgen command behaves differently in zsh.

# In bash (as expected):
$ compgen -W "one two three" -- "t"
two
three
# In zsh ("one" is not expected to be listed)
$ compgen -W "one two three" -- "t"
one
two
three

Despite that, completions still work - but I am trying to understand why these are different, and perhaps if there is a different compgen syntax that returns the same results in both shells.

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like