Files
nvm/test/install_script/nvm_reset
T
Jordan Harband 9abb216367 [Fix] install.sh: detect the profile from the login shell that ran the installer
`$SHELL` is the account's login shell,
so when a terminal runs a different shell,
like zsh from Terminal's settings without `chsh`,
the installer wrote to the other shell's profile.
Prefer the shell that ran the installer,
but only when it is a login shell,
since a script that runs the installer,
like a bash dotfiles bootstrap,
isn't the user's shell.

Fixes #592.
Closes #611, whose idea this is.
2026-11-22 12:24:35 -08:00

41 lines
1.5 KiB
Bash
Executable File

#!/bin/sh
cleanup () {
unset -f safe_type die cleanup
}
die () { echo "$@" ; cleanup ; exit 1; }
safe_type() {
type "$1"
}
# precondition: the names should be unset
! safe_type nvm_do_install || die 'nvm_do_install is still available'
! safe_type nvm_has || die 'nvm_has is still available'
! safe_type nvm_download || die 'nvm_download is still available'
! safe_type install_nvm_as_script || die 'install_nvm_as_script is still available'
! safe_type install_nvm_from_git || die 'install_nvm_from_git is still available'
! safe_type nvm_reset || die 'nvm_reset is still available'
! safe_type nvm_detect_profile || die 'nvm_detect_profile is still available'
! safe_type nvm_invoking_login_shell || die 'nvm_invoking_login_shell is still available'
NVM_ENV=testing \. ../../install.sh
# Check nvm_reset exists
safe_type nvm_reset || die 'nvm_reset is not available'
# Apply nvm_reset
nvm_reset || die 'nvm_reset failed'
# The names should be unset
! safe_type nvm_do_install || die 'nvm_do_install is still available'
! safe_type nvm_has || die 'nvm_has is still available'
! safe_type nvm_download || die 'nvm_download is still available'
! safe_type install_nvm_as_script || die 'install_nvm_as_script is still available'
! safe_type install_nvm_from_git || die 'install_nvm_from_git is still available'
! safe_type nvm_reset || die 'nvm_reset is still available'
! safe_type nvm_detect_profile || die 'nvm_detect_profile is still available'
! safe_type nvm_invoking_login_shell || die 'nvm_invoking_login_shell is still available'
cleanup