From aa1fccff4b9c005dd2fc1f8de16713274f8a7627 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Mon, 24 Oct 2016 15:45:30 +0100 Subject: [PATCH] Don't set lazy loaders that conflict with existing globals --- zsh-nvm.plugin.zsh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/zsh-nvm.plugin.zsh b/zsh-nvm.plugin.zsh index d48374a..ad10b05 100644 --- a/zsh-nvm.plugin.zsh +++ b/zsh-nvm.plugin.zsh @@ -78,12 +78,19 @@ _zsh_nvm_lazy_load() { # Add nvm global_binaries+=('nvm') + # Remove any binaries that conflict with current globals + local cmds + cmds=() + for bin in $global_binaries; do + _zsh_nvm_has $bin || cmds+=($bin) + done + # Create function for each command - for cmd in $global_binaries; do + for cmd in $cmds; do # When called, unset all lazy loaders, load nvm then run current command eval "$cmd(){ - unset -f $global_binaries + unset -f $cmds _zsh_nvm_load $cmd \"\$@\" }"