click-contrib / click-completion

Add or enhance bash, fish, zsh and powershell completion in Click
MIT License
288 stars 32 forks source link

Error when loading completion from zsh #7

Closed kbd closed 6 years ago

kbd commented 6 years ago

Under zsh, you run the following code:

if [[ "$(basename ${(%):-%x})" != "..." ]]; then

Under a login shell, the shell executable begins with a dash (eg. '-zsh'), so basename fails with:

$ eval "$(pipenv --completion)"
basename: illegal option -- z
usage: basename string [suffix]
       basename [-a] [-s suffix] string [...]

(pipenv uses click_completion internally.) To fix this, you can do:

basename -- ${(%):-%x}

Adding -- stops anything starting with - from being parsed as an argument.

glehmann commented 6 years ago

looks good to me. Could you submit a pull request with that fix?

glehmann commented 6 years ago

fixed in #10