c08b925d282e35ea7bd9a8f4c29de2ece0debb49
- Author
- Michele Bologna <michele.bologna@gmail.com>
- Committer
- GitHub <noreply@github.com>
- Date
Message
fix(uninstall): abort uninstall if unable to change shell (#10357)
Diff
1diff --git a/tools/uninstall.sh b/tools/uninstall.sh
2index 6a0e7b4c7440d1827c12bd733648a3f457b11542..6e3df7acac57b25a68cf7489b5c5fbe1a9d2ba99 100644
3--- a/tools/uninstall.sh
4+++ b/tools/uninstall.sh
5@@ -1,3 +1,15 @@
6+if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
7+ old_shell=$(cat ~/.shell.pre-oh-my-zsh)
8+ echo "Switching your shell back to '$old_shell':"
9+ if chsh -s "$old_shell"; then
10+ rm -f ~/.shell.pre-oh-my-zsh
11+ else
12+ echo "Could not change default shell. Change it manually by running chsh"
13+ echo "or editing the /etc/passwd file."
14+ exit
15+ fi
16+fi
17+
18 read -r -p "Are you sure you want to remove Oh My Zsh? [y/N] " confirmation
19 if [ "$confirmation" != y ] && [ "$confirmation" != Y ]; then
20 echo "Uninstall cancelled"
21@@ -25,16 +37,5 @@ else
22 echo "No original zsh config found"
23 fi
24
25-if hash chsh >/dev/null 2>&1 && [ -f ~/.shell.pre-oh-my-zsh ]; then
26- old_shell=$(cat ~/.shell.pre-oh-my-zsh)
27- echo "Switching your shell back to '$old_shell':"
28- if chsh -s "$old_shell"; then
29- rm -f ~/.shell.pre-oh-my-zsh
30- else
31- echo "Could not change default shell. Change it manually by running chsh"
32- echo "or editing the /etc/passwd file."
33- fi
34-fi
35-
36 echo "Thanks for trying out Oh My Zsh. It's been uninstalled."
37 echo "Don't forget to restart your terminal!"