Fix leaking variables using local with for loops

This commit is contained in:
Sumit Sahrawat 2023-07-12 17:55:57 +05:30
parent 9295d10c88
commit 8851053d21
No known key found for this signature in database
GPG Key ID: 33948B7403244BFF

View File

@ -98,11 +98,13 @@ _zsh_nvm_lazy_load() {
# Remove any binaries that conflict with current aliases # Remove any binaries that conflict with current aliases
local cmds local cmds
cmds=() cmds=()
local bin
for bin in $global_binaries; do for bin in $global_binaries; do
[[ "$(which $bin 2> /dev/null)" = "$bin: aliased to "* ]] || cmds+=($bin) [[ "$(which $bin 2> /dev/null)" = "$bin: aliased to "* ]] || cmds+=($bin)
done done
# Create function for each command # Create function for each command
local cmd
for cmd in $cmds; do for cmd in $cmds; do
# When called, unset all lazy loaders, load nvm then run current command # When called, unset all lazy loaders, load nvm then run current command