diff options
author | Marc Cornellà <hello@mcornella.com> | 2023-02-01 21:19:55 +0100 |
---|---|---|
committer | Marc Cornellà <hello@mcornella.com> | 2023-02-02 08:53:44 +0100 |
commit | 5c9a3d2f4f5cecc019b49d8fa3c151e547f8b139 (patch) | |
tree | 4fd6f2e519aa47397a327afd92d3ef381987996e /tools | |
parent | 27f31799df369ffdd825014bbbb853ad6a1ee520 (diff) | |
download | zsh-5c9a3d2f4f5cecc019b49d8fa3c151e547f8b139.tar.gz zsh-5c9a3d2f4f5cecc019b49d8fa3c151e547f8b139.tar.bz2 zsh-5c9a3d2f4f5cecc019b49d8fa3c151e547f8b139.zip |
fix(installer): don't use `$ZDOTDIR` in zshrc file if same as `$HOME`
Fixes #11471
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/install.sh | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/install.sh b/tools/install.sh index 4582ed03e..3ea12f8d4 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -61,9 +61,9 @@ custom_zsh=${ZSH:+yes} zdot="${ZDOTDIR:-$HOME}" # Default value for $ZSH -# a) if $ZDOTDIR is supplied: $ZDOTDIR/ohmyzsh +# a) if $ZDOTDIR is supplied and not $HOME: $ZDOTDIR/ohmyzsh # b) otherwise, $HOME/.oh-my-zsh -ZSH="${ZSH:-${ZDOTDIR:+$ZDOTDIR/ohmyzsh}}" +[ "$ZDOTDIR" = "$HOME" ] || ZSH="${ZSH:-${ZDOTDIR:+$ZDOTDIR/ohmyzsh}}" ZSH="${ZSH:-$HOME/.oh-my-zsh}" # Default settings @@ -350,7 +350,9 @@ setup_zshrc() { # Modify $ZSH variable in .zshrc directory to use the literal $ZDOTDIR or $HOME omz="$ZSH" - [ -z "$ZDOTDIR" ] || omz=$(echo "$omz" | sed "s|^$ZDOTDIR/|\$ZDOTDIR/|") + if [ -n "$ZDOTDIR" ] && [ "$ZDOTDIR" != "$HOME" ]; then + omz=$(echo "$omz" | sed "s|^$ZDOTDIR/|\$ZDOTDIR/|") + fi omz=$(echo "$omz" | sed "s|^$HOME/|\$HOME/|") sed "s|^export ZSH=.*$|export ZSH=\"${omz}\"|" "$ZSH/templates/zshrc.zsh-template" > "$zdot/.zshrc-omztemp" |