502f08b5e19716d43a7ec8b006178a7b017f68cd

Author
Andrew Janke <janke@pobox.com>
Committer
Andrew Janke <andrew@apjanke.net>
Date

Message

Add Cygwin support to installer.
* Balk at incompatible Windows/MSYS git
* Test for chsh presence before trying to use it
* Replace non-portable `[[ ... ]]` and `[ x = *pattern* ]` constructs

Diff

 1diff --git a/tools/install.sh b/tools/install.sh
 2index c83a6f23d0776abec9a189f90d0846d8d3036ab0..1da261cf9ac83f233624b6e71ddfb5b7d458da19 100755
 3--- a/tools/install.sh
 4+++ b/tools/install.sh
 5@@ -10,9 +10,21 @@ if [ -d "$ZSH" ]; then
 6 fi
 7 
 8 echo "\033[0;34mCloning Oh My Zsh...\033[0m"
 9-hash git >/dev/null 2>&1 && env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
10-  echo "git not installed"
11-  exit
12+hash git >/dev/null 2>&1 || {
13+  echo "Error: git is not installed"
14+  exit 1
15+}
16+# The Windows (MSYS) Git is not compatible with normal use on cygwin
17+if [ "$OSTYPE" = cygwin ]; then
18+  if git --version | grep msysgit > /dev/null; then
19+    echo "Error: Windows/MSYS Git is not supported on Cygwin"
20+    echo "Error: Make sure the Cygwin git package is installed and is first on the path"
21+    exit 1
22+  fi
23+fi
24+env git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git $ZSH || {
25+  echo "Error: git clone of oh-my-zsh repo failed"
26+  exit 1
27 }
28 
29 echo "\033[0;34mLooking for an existing zsh config...\033[0m"
30@@ -34,8 +46,13 @@ export PATH=\"$PATH\"
31 
32 TEST_CURRENT_SHELL=$(expr "$SHELL" : '.*/\(.*\)')
33 if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
34+  if hash chsh >/dev/null 2>&1; then
35     echo "\033[0;34mTime to change your default shell to zsh!\033[0m"
36     chsh -s $(grep /zsh$ /etc/shells | tail -1)
37+  else
38+    echo "I can't change your shell automatically because this system does not have chsh."
39+    echo "Please edit /etc/passwd to set your default shell to zsh."
40+  fi
41 fi
42 unset TEST_CURRENT_SHELL
43 
44diff --git a/tools/uninstall.sh b/tools/uninstall.sh
45index 41d6015769d4c7a5ef06d087c58f80bf6a07a106..23bfac0eb5f07907fa844c2aafb029872fdbef2d 100644
46--- a/tools/uninstall.sh
47+++ b/tools/uninstall.sh
48@@ -1,5 +1,5 @@
49 echo "Removing ~/.oh-my-zsh"
50-if [[ -d ~/.oh-my-zsh ]]
51+if [ -d ~/.oh-my-zsh ]
52 then
53   rm -rf ~/.oh-my-zsh
54 fi
55@@ -20,9 +20,13 @@ then
56 
57   source ~/.zshrc;
58 else
59-  echo "Switching back to bash"
60-  chsh -s /bin/bash
61-  source /etc/profile
62+  if hash chsh >/dev/null 2>&1
63+  then
64+    echo "Switching back to bash"
65+    chsh -s /bin/bash
66+  else
67+    echo "You can edit /etc/passwd to switch your default shell back to bash"
68+  fi
69 fi
70 
71 echo "Thanks for trying out Oh My Zsh. It's been uninstalled."