[readme] cdnvm: let nvm parse .nvmrc, so a symlinked .nvmrc's content is not printed
The bash `cdnvm` example read `.nvmrc` raw and passed its content to `nvm ls`, `nvm install`, and `nvm use`, so a `.nvmrc` symlinked to any readable file had that file's content printed in a "not found" error, bypassing the protection that `nvm_process_nvmrc` gives `nvm use`. It now gets the version from `nvm_process_nvmrc`, which refuses a symlinked `.nvmrc` that does not contain a version or alias without showing its content, and also strips comments, which the raw read passed along.
This commit is contained in:
1 file changed
+3
-1
@@ -814,7 +814,9 @@ cdnvm() {
|
||||
fi
|
||||
elif [[ -s "${nvm_path}/.nvmrc" && -r "${nvm_path}/.nvmrc" ]]; then
|
||||
declare nvm_version
|
||||
nvm_version=$(<"${nvm_path}"/.nvmrc)
|
||||
# Let nvm parse `.nvmrc`, so that comments are ignored and the content of an invalid
|
||||
# or symlinked `.nvmrc` is not passed along to other nvm commands, which may print it
|
||||
nvm_version="$(nvm_process_nvmrc "${nvm_path}/.nvmrc")" || return
|
||||
|
||||
declare locally_resolved_nvm_version
|
||||
# `nvm ls` will check all locally-available versions
|
||||
|
||||
Reference in new issue
Block a user