[Fix] ls: list versions whose directory is a symlink

nvm_ls collects installed versions with `find <dirs>/* -name . -o -type d -prune -o -path ...`,
and `-type d` is false for a symlink,
so a version dir that links to another volume was skipped from the listing entirely
- while `nvm version`, `nvm which` and `nvm use` all kept working on it.

Have that find follow symlinks,
which makes linked-in versions visible and still ignores a broken link.

Fixes #617.
This commit is contained in:
NUAAwqy authored and Jordan Harband committed 2026-10-29 14:59:29 +00:00
1 parent 970ed9ea18
commit c6bf252f7d
3 files changed
+29 -1

No files matched your search

+1 -1
View File
@@ -2516,7 +2516,7 @@ nvm_ls() {
NVM_DIR_SED="$(nvm_echo "${NVM_DIR}" | command sed 's/[][\.*^$#]/\\&/g')"
local NVM_VERSION_DIR_IOJS_SED
NVM_VERSION_DIR_IOJS_SED="$(nvm_echo "${NVM_VERSION_DIR_IOJS}" | command sed 's/[][\.*^$#]/\\&/g')"
VERSIONS="$(command find "${NVM_DIRS_TO_SEARCH1}"/* "${NVM_DIRS_TO_SEARCH2}"/* "${NVM_DIRS_TO_SEARCH3}"/* -name . -o -type d -prune -o -path "${PATTERN}*" \
VERSIONS="$(command find -L "${NVM_DIRS_TO_SEARCH1}"/* "${NVM_DIRS_TO_SEARCH2}"/* "${NVM_DIRS_TO_SEARCH3}"/* -name . -o -type d -prune -o -path "${PATTERN}*" \
| command sed -e "
s#${NVM_VERSION_DIR_IOJS_SED}/#versions/${NVM_IOJS_PREFIX}/#;
s#^${NVM_DIR_SED}/##;