1
0
mirror of https://github.com/nvm-sh/nvm.git synced 2026-10-23 23:03:46 +08:00

[Refactor] nvm_alias: one-pass trailing whitespace strip

Replace the per-character trailing-whitespace loop with a one-pass
parameter expansion, per review.
This commit is contained in:
Jake Lodwick
2026-05-05 23:32:58 -04:00
committed by Jordan Harband
parent 304a22ad59
commit 0a9dead76d

7
nvm.sh
View File

@@ -1377,12 +1377,7 @@ nvm_alias() {
*[![:space:]]*) ;;
*) continue ;;
esac
while : ; do
case "${NVM_ALIAS_LINE}" in
*[[:space:]]) NVM_ALIAS_LINE="${NVM_ALIAS_LINE%[[:space:]]}" ;;
*) break ;;
esac
done
NVM_ALIAS_LINE="${NVM_ALIAS_LINE%"${NVM_ALIAS_LINE##*[![:space:]]}"}"
nvm_echo "${NVM_ALIAS_LINE}"
done < "${NVM_ALIAS_PATH}"
}