5c9a3d2f4f5cecc019b49d8fa3c151e547f8b139
- Author
- Marc Cornellà <hello@mcornella.com>
- Committer
- Marc Cornellà <hello@mcornella.com>
- Date
Message
fix(installer): don't use `$ZDOTDIR` in zshrc file if same as `$HOME`
Fixes #11471
Diff
1diff --git a/tools/install.sh b/tools/install.sh
2index 4582ed03ee5977a208a8c07dca2d7a1ca4a31609..3ea12f8d45d35f33f1dfc10c67cfedbbb4842bca 100755
3--- a/tools/install.sh
4+++ b/tools/install.sh
5@@ -61,9 +61,9 @@ custom_zsh=${ZSH:+yes}
6 zdot="${ZDOTDIR:-$HOME}"
7
8 # Default value for $ZSH
9-# a) if $ZDOTDIR is supplied: $ZDOTDIR/ohmyzsh
10+# a) if $ZDOTDIR is supplied and not $HOME: $ZDOTDIR/ohmyzsh
11 # b) otherwise, $HOME/.oh-my-zsh
12-ZSH="${ZSH:-${ZDOTDIR:+$ZDOTDIR/ohmyzsh}}"
13+[ "$ZDOTDIR" = "$HOME" ] || ZSH="${ZSH:-${ZDOTDIR:+$ZDOTDIR/ohmyzsh}}"
14 ZSH="${ZSH:-$HOME/.oh-my-zsh}"
15
16 # Default settings
17@@ -350,7 +350,9 @@ setup_zshrc() {
18
19 # Modify $ZSH variable in .zshrc directory to use the literal $ZDOTDIR or $HOME
20 omz="$ZSH"
21- [ -z "$ZDOTDIR" ] || omz=$(echo "$omz" | sed "s|^$ZDOTDIR/|\$ZDOTDIR/|")
22+ if [ -n "$ZDOTDIR" ] && [ "$ZDOTDIR" != "$HOME" ]; then
23+ omz=$(echo "$omz" | sed "s|^$ZDOTDIR/|\$ZDOTDIR/|")
24+ fi
25 omz=$(echo "$omz" | sed "s|^$HOME/|\$HOME/|")
26
27 sed "s|^export ZSH=.*$|export ZSH=\"${omz}\"|" "$ZSH/templates/zshrc.zsh-template" > "$zdot/.zshrc-omztemp"