tomwadley / aur-nvm

Mirror of nvm AUR repo
https://aur.archlinux.org/packages/nvm/
0 stars 0 forks source link

Don't run bash code if zsh #1

Open HaleTom opened 5 years ago

HaleTom commented 5 years ago
source /usr/share/nvm/bash_completion

Can this be wrapped with:

[ -n $BASH_VERSION] && ...
HaleTom commented 5 years ago

Errors occur with the current version.

tomwadley commented 5 years ago

The bash_completion file shipped with nvm is supposed to support zsh by loading bashcompinit: https://github.com/creationix/nvm/blob/217a5bb0de8290a229fdceba4671e3c219b68549/bash_completion#L83

I don't use zsh but I fired it up to test it and it seemed to work, at least with my empty .zshrc configuration.

Having said that, the bash_completion script should arguably be installed to /usr/share/bash-completion/completions/ so it would get sourced by bash automatically. I think I didn't put it there originally because nvm gets sourced by the user and so doesn't exist when bash_completion is first loaded. But it looks like bash_completion dynamically sources the completion files when needed so it still seems to work. My only concern is that by moving the completion script out of init-nvm.sh, zsh users whom this completion file does work for, will now need an extra step to enable completions.