[New] `install.sh`: add `$ZDOTDIR` to zsh search
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Fixes #3128
authored by menaechmi · committed by Jordan Harband · parent d648a3b · Browse files · 2 files·+33 added−8 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+33 added−8 removed
- tests:+29 added−4 removed
- other:+4 added−4 removed
Provenance
- Commit
cd22c84- Tree
4c567d7- Author
menaechmi <menaechmi@protonmail.com>- Committer
Jordan Harband <ljharb@gmail.com>- Parent
d648a3b
2 files changed+33 added−8 removed
modified:test/install_script/nvm_detect_profile+29 added-4 removed
1 unmodified line2 3 setup () {4 HOME="."5 NVM_ENV=testing \. ../../install.sh6+ ZDOTDIR="$HOME/zdotdir"7+ mkdir -p zdotdir8 touch ".bashrc"9 touch ".bash_profile"10 touch ".zprofile"11 touch ".zshrc"12 touch ".profile"13 touch "test_profile"14+ touch "zdotdir/.zshrc"15+ touch "zdotdir/.zprofile"16 }17 18 cleanup () {19 unset HOME20 unset NVM_ENV21 unset NVM_DETECT_PROFILE22 unset SHELL23 unset -f setup cleanup die24+ unset ZDOTDIR25 rm -f ".bashrc" ".bash_profile" ".zprofile" ".zshrc" ".profile" "test_profile" > "/dev/null" 2>&126+ rm -rf zdot>&127 }28 29 die () { echo "$@" '$NVM_DETECT_PROFILE:' "$NVM_DETECT_PROFILE"; cleanup; exit 1; }30 20 unmodified lines51 if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then52 die "nvm_detect_profile ignored \$PROFILE"53 fi54 49-# .zshrc should be detected for zsh55+# zdotdir/.zshrc should be detected for zsh56 NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; nvm_detect_profile)"57+if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then58+ die "nvm_detect_profile didn't pick \$ZDOTDIR/.zshrc for zsh"59+fi60+61+# .zshrc should be detected for zsh62+NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; unset ZDOTDIR; nvm_detect_profile)"63 if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then64 die "nvm_detect_profile didn't pick \$HOME/.zshrc for zsh"65 fi66 2 unmodified lines69 if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then70 die "nvm_detect_profile ignored \$PROFILE"71 fi72 61-73 #74 # Confirm $PROFILE is only returned when it points to a valid file75 #76 35 unmodified lines112 if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then113 die "nvm_detect_profile should have selected .bash_profile"114 fi115 105-# Otherwise, it should favor .zprofile if file exists116+# Otherwise, it should favor zdotdir/.zprofile if file exists117 rm ".bash_profile"118 NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"119+if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zprofile" ]; then120+ die "nvm_detect_profile should have selected zdotdir/.zprofile"121+fi122+123+# Otherwise, it should favor .zprofile if file exists124+rm "zdotdir/.zprofile"125+NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"126 if [ "$NVM_DETECT_PROFILE" != "$HOME/.zprofile" ]; then127 die "nvm_detect_profile should have selected .zprofile"128 fi129 112-# Otherwise, it should favor .zshrc if file exists130+# Otherwise, it should favor zdotdir/.zshrc if file exists131 rm ".zprofile"132 NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"133+if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then134+ die "nvm_detect_profile should have selected zdotdir/.zshrc"135+fi136+137+# Otherwise, it should favor .zshrc if file exists138+rm "zdotdir/.zshrc"139+NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"140 if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then141 die "nvm_detect_profile should have selected .zshrc"142 fi143 8 unmodified linesmodified:install.sh+4 added-4 removed
294 unmodified lines295 elif [ -f "$HOME/.bash_profile" ]; then296 DETECTED_PROFILE="$HOME/.bash_profile"297 fi298 elif [ "${SHELL#*zsh}" != "$SHELL" ]; then299- if [ -f "$HOME/.zshrc" ]; then300- DETECTED_PROFILE="$HOME/.zshrc"301- elif [ -f "$HOME/.zprofile" ]; then302- DETECTED_PROFILE="$HOME/.zprofile"299+ if [ -f "${ZDOTDIR:-${HOME}}/.zshrc" ]; then300+ DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zshrc"301+ elif [ -f "${ZDOTDIR:-${HOME}}/.zprofile" ]; then302+ DETECTED_PROFILE="${ZDOTDIR:-${HOME}}/.zprofile"303 fi304 fi305 306 if [ -z "$DETECTED_PROFILE" ]; then189 unmodified lines