commit | 86708833c911dd01597d43f2dc4570b35f1d9aaa | [log] [tgz] |
---|---|---|
author | Keith Lazuka <klazuka@gmail.com> | Tue Dec 08 12:28:24 2020 -0500 |
committer | Jordan Harband <ljharb@gmail.com> | Tue Dec 08 12:28:24 2020 -0500 |
tree | 9117698ebe4a36176528eac5dd4bd18cf81512c8 | |
parent | d4eba354b5da6195e4017c0baa3c5664d9db1d1d [diff] |
[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
diff --git a/nvm.sh b/nvm.sh index 5a27ae6..2e85e6a 100644 --- a/nvm.sh +++ b/nvm.sh
@@ -2554,6 +2554,7 @@ return $? fi + local i for i in "$@" do case $i in