mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-12 21:39:48 +01:00
installer: improve zsh binary path search in setup_shell
This changes the behavior to default to the binary found first in $PATH, then checking it's actually in the shells file (/etc/shells). If that fails go back to the previous behavior, but actually check that the path obtained exists in the filesystem. Co-authored-by: Joel Kuzmarski <leoj3n@gmail.com>
This commit is contained in:
parent
9d2b3ce79f
commit
a6a093ba2a
1 changed files with 12 additions and 1 deletions
|
@ -117,7 +117,18 @@ setup_shell() {
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! chsh -s $(grep '^/.*/zsh$' "$shells_file" | tail -1); then
|
# Get the path to the right zsh binary
|
||||||
|
# 1. Use the most preceding one based on $PATH, then check that it's in the shells file
|
||||||
|
# 2. If that fails, get a zsh path from the shells file, then check it actually exists
|
||||||
|
if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then
|
||||||
|
if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then
|
||||||
|
error "no available zsh binary found. Change your default shell manually."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Actually change the default shell to zsh
|
||||||
|
if ! chsh -s "$zsh"; then
|
||||||
error "chsh command unsuccessful. Change your default shell manually."
|
error "chsh command unsuccessful. Change your default shell manually."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue