Skip to content
Myr

[Fix] `nvm uninstall`: fix alias cleanup glob expansion

Before adoption: this commit came in with the history the project adopted, so no landing records it.

The `*` glob was inside double quotes, preventing shell expansion. `nvm_grep -l` received a literal `*` filename instead of the list of alias files, so aliases pointing to uninstalled versions were never cleaned up. Bug introduced in https://github.com/nvm-sh/nvm/commit/7807a9f09e54a14f9b493c6eeda0022489cda496.

authored by Jordan Harband · committed by Jordan Harband · parent 32863e1 · Browse files · 2 files+25 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+25 added−1 removed

  • tests:+24 added−0 removed
  • other:+1 added−1 removed

2 files+25 added−1 removed

added:test/fast/Running 'nvm uninstall' should clean up aliases pointing to uninstalled version+24 added
1#!/bin/sh23die() { echo "$@" >&2; exit 1; }45set -ex67: nvm.sh8\. ../../nvm.sh9\. ../common.sh1011make_fake_node v0.0.11213nvm alias test_alias v0.0.11415# Verify alias was created16[ -f "$(nvm_alias_path)/test_alias" ] || die "alias file should exist before uninstall"1718nvm uninstall v0.0.11920# Verify the version directory was removed21[ ! -d "$(nvm_version_path v0.0.1)" ] || die "version directory should be removed"2223# Verify the alias was cleaned up24[ ! -f "$(nvm_alias_path)/test_alias" ] || die "alias file should be removed after uninstalling the version it points to"
modified:nvm.sh+1 added-1 removed
3904 unmodified lines
3905 "${VERSION_PATH}" 2>/dev/null3906 nvm_echo "${NVM_SUCCESS_MSG}"39073908 # rm any aliases that point to uninstalled version.3909 for ALIAS in $(nvm_grep -l "${VERSION}" "$(nvm_alias_path)/*" 2>/dev/null); do3909 for ALIAS in $(nvm_grep -l "${VERSION}" "$(nvm_alias_path)"/* 2>/dev/null); do3910 nvm unalias "$(command basename "${ALIAS}")"3911 done3912 ;;3913 "deactivate")
907 unmodified lines