702a594df3b49f40496e4840cae2d93c83d5bc4d

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

Message

installer: don't rely on tput for coloring

tput is error-prone and may not be needed, since all the formatting
codes used are standard across all types of terminals.

Diff

 1diff --git a/tools/install.sh b/tools/install.sh
 2index d56d8addc7bbb10858d16e5d62d1feff3ca1b862..17b70bfea089ff5227fe5435097cddff338f3ea6 100755
 3--- a/tools/install.sh
 4+++ b/tools/install.sh
 5@@ -50,25 +50,22 @@ error() {
 6 	echo ${RED}"Error: $@"${RESET} >&2
 7 }
 8 
 9-# Set up color sequences
10 setup_color() {
11-	ncolors=$(tput colors 2>/dev/null) || ncolors=0
12-
13-	# Only use colors if connected to a terminal that supports them
14-	if [ -t 1 ] && [ $ncolors -ge 8 ]; then
15-		RED="$(tput setaf 1)"
16-		GREEN="$(tput setaf 2)"
17-		YELLOW="$(tput setaf 3)"
18-		BLUE="$(tput setaf 4)"
19-		BOLD="$(tput bold)"
20-		RESET="$(tput sgr0)"
21-	else
22+	# Only use colors if connected to a terminal
23+	if [ -t 1 ]; then
24 		RED=$(printf '\033[31m')
25 		GREEN=$(printf '\033[32m')
26 		YELLOW=$(printf '\033[33m')
27 		BLUE=$(printf '\033[34m')
28 		BOLD=$(printf '\033[1m')
29 		RESET=$(printf '\033[m')
30+	else
31+		RED=""
32+		GREEN=""
33+		YELLOW=""
34+		BLUE=""
35+		BOLD=""
36+		RESET=""
37 	fi
38 }
39