From 6fc0241c21ce8f570f34ce978a3746874664d648 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Sun, 12 Feb 2017 00:32:49 -0800 Subject: [PATCH] [Fix] `install.sh`: only un-interpolate $HOME for the profile source string. Fixes #1384. --- install.sh | 10 +++++----- test/install_script/nvm_install_dir | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 85babf5..fc0658b 100755 --- a/install.sh +++ b/install.sh @@ -7,7 +7,7 @@ nvm_has() { } nvm_install_dir() { - printf %s "${NVM_DIR:-"$HOME/.nvm"}" | sed "s:^$HOME:\$HOME:" + printf %s "${NVM_DIR:-"$HOME/.nvm"}" } nvm_latest_version() { @@ -290,10 +290,10 @@ nvm_do_install() { local NVM_PROFILE NVM_PROFILE="$(nvm_detect_profile)" - local INSTALL_DIR - INSTALL_DIR="$(nvm_install_dir)" + local PROFILE_INSTALL_DIR + PROFILE_INSTALL_DIR="$(nvm_install_dir| sed "s:^$HOME:\$HOME:")" - SOURCE_STR="\nexport NVM_DIR=\"$INSTALL_DIR\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\" # This loads nvm\n" + SOURCE_STR="\nexport NVM_DIR=\"${PROFILE_INSTALL_DIR}\"\n[ -s \"\$NVM_DIR/nvm.sh\" ] && \\. \"\$NVM_DIR/nvm.sh\" # This loads nvm\n" COMPLETION_STR="[ -s \"\$NVM_DIR/bash_completion\" ] && \\. \"\$NVM_DIR/bash_completion\" # This loads nvm bash_completion\n" BASH_OR_ZSH=false @@ -331,7 +331,7 @@ nvm_do_install() { # Source nvm # shellcheck source=/dev/null - \. "${INSTALL_DIR}/nvm.sh" + \. "$(nvm_install_dir)/nvm.sh" nvm_check_global_modules diff --git a/test/install_script/nvm_install_dir b/test/install_script/nvm_install_dir index 94c784f..1c685e3 100755 --- a/test/install_script/nvm_install_dir +++ b/test/install_script/nvm_install_dir @@ -19,7 +19,7 @@ unset NVM_DIR # NVM_DIR is not set install_dir=$(nvm_install_dir) -[ "_$install_dir" = "_\$HOME/.nvm" ] || die "nvm_install_dir should default to \$HOME/.nvm. Current output: $install_dir" +[ "_$install_dir" = "_$HOME/.nvm" ] || die "nvm_install_dir should default to \$HOME/.nvm. Current output: $install_dir" cleanup