Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use local variable when looping over args #2377

Merged
merged 1 commit into from
Dec 8, 2020
Merged

Conversation

klazuka
Copy link
Contributor

@klazuka klazuka commented Dec 8, 2020

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

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
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, totally reasonable fix. I don't think this needs tests.

@ljharb ljharb merged commit 8670883 into nvm-sh:master Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants