Skip to content
Myr

[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

2 files+33 added−8 removed

modified:test/install_script/nvm_detect_profile+29 added-4 removed
1 unmodified line
23setup () {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}1718cleanup () {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}2829die () { echo "$@" '$NVM_DETECT_PROFILE:' "$NVM_DETECT_PROFILE"; cleanup; exit 1; }30
20 unmodified lines
51if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then52 die "nvm_detect_profile ignored \$PROFILE"53fi5449# .zshrc should be detected for zsh55# zdotdir/.zshrc should be detected for zsh56NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; nvm_detect_profile)"57if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then58 die "nvm_detect_profile didn't pick \$ZDOTDIR/.zshrc for zsh"59fi6061# .zshrc should be detected for zsh62NVM_DETECT_PROFILE="$(SHELL="/bin/zsh"; unset PROFILE; unset ZDOTDIR; nvm_detect_profile)"63if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then64 die "nvm_detect_profile didn't pick \$HOME/.zshrc for zsh"65fi66
2 unmodified lines
69if [ "$NVM_DETECT_PROFILE" != "test_profile" ]; then70 die "nvm_detect_profile ignored \$PROFILE"71fi726173#74# Confirm $PROFILE is only returned when it points to a valid file75#76
35 unmodified lines
112if [ "$NVM_DETECT_PROFILE" != "$HOME/.bash_profile" ]; then113 die "nvm_detect_profile should have selected .bash_profile"114fi115105# Otherwise, it should favor .zprofile if file exists116# Otherwise, it should favor zdotdir/.zprofile if file exists117rm ".bash_profile"118NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"119if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zprofile" ]; then120 die "nvm_detect_profile should have selected zdotdir/.zprofile"121fi122123# Otherwise, it should favor .zprofile if file exists124rm "zdotdir/.zprofile"125NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"126if [ "$NVM_DETECT_PROFILE" != "$HOME/.zprofile" ]; then127 die "nvm_detect_profile should have selected .zprofile"128fi129112# Otherwise, it should favor .zshrc if file exists130# Otherwise, it should favor zdotdir/.zshrc if file exists131rm ".zprofile"132NVM_DETECT_PROFILE="$(unset SHELL; nvm_detect_profile)"133if [ "$NVM_DETECT_PROFILE" != "$ZDOTDIR/.zshrc" ]; then134 die "nvm_detect_profile should have selected zdotdir/.zshrc"135fi136137# Otherwise, it should favor .zshrc if file exists138rm "zdotdir/.zshrc"139NVM_DETECT_PROFILE="$(unset SHELL; unset ZDOTDIR; nvm_detect_profile)"140if [ "$NVM_DETECT_PROFILE" != "$HOME/.zshrc" ]; then141 die "nvm_detect_profile should have selected .zshrc"142fi143
8 unmodified lines
modified:install.sh+4 added-4 removed
294 unmodified lines
295 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 fi305306 if [ -z "$DETECTED_PROFILE" ]; then
189 unmodified lines