Diff
1diff --git a/tools/install.sh b/tools/install.sh
2index 2e5e8fd43351a6242f5f45b9245d6e80e35092ec..5c5419b1783e0cf045b2dfd062324e2a976c7e06 100755
3--- a/tools/install.sh
4+++ b/tools/install.sh
5@@ -1,8 +1,16 @@
6+#!/bin/sh
7+set -e
8+
9+# Test command existence (POSIX compatible)
10+command_exists() {
11+ command -v "$@" >/dev/null 2>&1
12+}
13+
14 main() {
15 # Use colors, but only if connected to a terminal, and that terminal
16 # supports them.
17- if which tput >/dev/null 2>&1; then
18- ncolors=$(tput colors)
19+ if command_exists tput; then
20+ ncolors=$(tput colors)
21 fi
22 if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
23 RED="$(tput setaf 1)"
24@@ -20,13 +28,9 @@ main() {
25 NORMAL=""
26 fi
27
28- # Only enable exit-on-error after the non-critical colorization stuff,
29- # which may fail on systems lacking tput or terminfo
30- set -e
31-
32- if ! command -v zsh >/dev/null 2>&1; then
33+ if ! command_exists zsh; then
34 printf "${YELLOW}Zsh is not installed!${NORMAL} Please install zsh first!\n"
35- exit
36+ exit 1
37 fi
38
39 if [ ! -n "$ZSH" ]; then
40@@ -36,7 +40,7 @@ main() {
41 if [ -d "$ZSH" ]; then
42 printf "${YELLOW}You already have Oh My Zsh installed.${NORMAL}\n"
43 printf "You'll need to remove $ZSH if you want to re-install.\n"
44- exit
45+ exit 1
46 fi
47
48 # Prevent the cloned repository from having insecure permissions. Failing to do
49@@ -47,7 +51,7 @@ main() {
50 umask g-w,o-w
51
52 printf "${BLUE}Cloning Oh My Zsh...${NORMAL}\n"
53- command -v git >/dev/null 2>&1 || {
54+ command_exists git || {
55 echo "Error: git is not installed"
56 exit 1
57 }
58@@ -82,7 +86,7 @@ main() {
59 TEST_CURRENT_SHELL=$(basename "$SHELL")
60 if [ "$TEST_CURRENT_SHELL" != "zsh" ]; then
61 # If this platform provides a "chsh" command (not Cygwin), do it, man!
62- if hash chsh >/dev/null 2>&1; then
63+ if command_exists chsh; then
64 printf "${BLUE}Time to change your default shell to zsh!${NORMAL}\n"
65 chsh -s $(grep /zsh$ /etc/shells | tail -1)
66 # Else, suggest the user do so manually.