[Fix] Parse commented nvmrc content in nvm_ls#3854
Merged
Conversation
Fixes nvm-sh#3761 Signed-off-by: jinhyuk9714 <jinhyuk9714@gmail.com>
This comment was marked as spam.
This comment was marked as spam.
…R, cover the sed path
- `cleanup` unset TEST_DIR before `rm -rf "${TEST_DIR-}"`, so the temp dir (with an executable fake `node`) was never removed,
and urchin executes any executable file it finds under the test dir on the next local run.
- the preexisting `foo#bar` assertions ran against the ambient NVM_DIR;
now that `#` patterns comment-strip to `foo`, a real local alias named `foo` would resolve and break them,
so all assertions now run against an isolated NVM_DIR.
- the multiline content used a full x.y.z version, which takes nvm_ls's explicit-version fast path and never reaches the find/sed pipeline where the newline actually broke sed;
a partial version exercises that path, and matching on "unterminated" covers both the BSD and GNU sed error wordings.
d886cca to
21d33ef
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #3761.
The documented shell integrations pass raw
.nvmrccontents tonvm version. When those contents include comments,nvm_lsused the raw value in its sed search expression, which could trigger anunterminated regular expressionerror. This reuses the.nvmrcparser for commented or multiline patterns before local version matching.Changes
.nvmrccontent parsing intonvm_process_nvmrc_content..nvmrcpatterns innvm_ls..nvmrccontent throughnvm_lsandnvm_version.Testing
for shell in sh bash dash zsh; do printf '== %s ==\n' "$shell"; "$shell" './nvm_ls handles hash in pattern' || exit $?; donefor shell in sh bash dash zsh; do printf '== %s ==\n' "$shell"; "$shell" './nvm_process_nvmrc' || exit $?; donefor shell in sh bash dash zsh; do printf '== %s ==\n' "$shell"; "$shell" './nvm_version' || exit $?; donefor shell in bash dash zsh; do printf '== %s -n ==\n' "$shell"; "$shell" -n nvm.sh || exit $?; donenpm run test:check-nonexecgit diff --checkNote: I used Codex while preparing this change, reviewed the final diff, and ran the listed checks locally.