Fix change to old shell on uninstall (#8430)
If there's no `~/.shell.pre-oh-my-zsh`, don't assume the default choice
is Bash. In fact Zsh is the default shell for macOS since Catalina
(10.15) [1], yet users of other OSes have likely to have Bash as their
default.
This commit fix issue #8252
[1] https://support.apple.com/en-us/HT208050
Diff
1diff --git a/tools/uninstall.sh b/tools/uninstall.sh
2index da31a6a14d6520654aa7a4f590cc4a9e7706573f..b327a016300a84551c8dbd4d2a89c2ba9de3f427 100644
3--- a/tools/uninstall.sh
4+++ b/tools/uninstall.sh
5@@ -25,18 +25,14 @@ if [ -e "$ZSHRC_ORIG" ]; then
6 echo "Your original zsh config was restored."
7 fi
8 9-if hash chsh >/dev/null 2>&1; then
10- if [ -f ~/.shell.pre-oh-my-zsh ]; then
11- old_shell=$(cat ~/.shell.pre-oh-my-zsh)
12- else
13- old_shell=/bin/bash
14- fi
15+if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
16+ old_shell=$(cat ~/.shell.pre-oh-my-zsh)
17 echo "Switching your shell back to '$old_shell':"
18 if chsh -s "$old_shell"; then
19 rm -f ~/.shell.pre-oh-my-zsh
20 else
21 echo "Could not change default shell. Change it manually by running chsh"
22- echo "or editing the /etc/passwd file."
23+ echo "or editing the /etc/passwd file."
24 fi
25 fi
26