1fdd5351fbea83293c510a4457ada799ae407a8b

Author
Marc Cornellà <marc.cornella@live.com>
Committer
Marc Cornellà <marc.cornella@live.com>
Date

Message

installer: abstract error messages

Diff

 1diff --git a/tools/install.sh b/tools/install.sh
 2index 446e7f416994ae8acef8da61c49fae6e86baa41f..884080c30487bd0d42c5bc6c3229cacb901e4153 100755
 3--- a/tools/install.sh
 4+++ b/tools/install.sh
 5@@ -17,6 +17,10 @@ command_exists() {
 6 	command -v "$@" >/dev/null 2>&1
 7 }
 8 
 9+error() {
10+	echo "Error: $@" >&2
11+}
12+
13 # Set up color sequences
14 setup_color() {
15 	if command_exists tput; then
16@@ -54,20 +58,18 @@ setup_ohmyzsh() {
17 	echo "${BLUE}Cloning Oh My Zsh...${NORMAL}"
18 
19 	command_exists git || {
20-		echo "Error: git is not installed"
21+		error "git is not installed"
22 		exit 1
23 	}
24 
25 	if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then
26-		cat <<-EOF
27-			Error: Windows/MSYS Git is not supported on Cygwin
28-			Error: Make sure the Cygwin git package is installed and is first on the $PATH
29-		EOF
30+		error "Windows/MSYS Git is not supported on Cygwin"
31+		error "Make sure the Cygwin git package is installed and is first on the \$PATH"
32 		exit 1
33 	fi
34 
35 	git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git "$ZSH" || {
36-		echo "Error: git clone of oh-my-zsh repo failed"
37+		error "git clone of oh-my-zsh repo failed"
38 		exit 1
39 	}
40 }
41@@ -96,7 +98,7 @@ setup_shell() {
42 		if command_exists chsh; then
43 			echo "${BLUE}Time to change your default shell to zsh!${NORMAL}"
44 			if ! chsh -s $(grep /zsh$ /etc/shells | tail -1); then
45-				echo "Error: chsh command unsuccessful. Change your default shell manually."
46+				error "chsh command unsuccessful. Change your default shell manually."
47 			fi
48 		# Else, suggest the user do so manually.
49 		else
50@@ -119,7 +121,7 @@ main() {
51 	if [ -d "$ZSH" ]; then
52 		cat <<-EOF
53 			${YELLOW}You already have Oh My Zsh installed.${NORMAL}
54-			You'll need to remove $ZSH if you want to reinstall.
55+			You'll need to remove '$ZSH' if you want to reinstall.
56 		EOF
57 		exit 1
58 	fi