[Fix] Use local variable when looping over args

When the `nvm` function is called by a script which itself uses a variable
named `i`, `nvm` clobbers the caller's variable. This happens even if the
caller has declared its variable as local.

See note 1 on https://tldp.org/LDP/abs/html/localvar.html#FTN.AEN18568
Keith Lazuka 2020-12-08 12:28:24 -05:00 committed by Jordan Harband
parent d4eba354b5
commit 86708833c9
No known key found for this signature in database
GPG Key ID: 9F6A681E35EF8B56
1 changed files with 1 additions and 0 deletions

1
nvm.sh
View File

@ -2554,6 +2554,7 @@ nvm() {
return $?
fi
local i
for i in "$@"
do
case $i in