summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarc Cornellà <marc.cornella@live.com>2019-06-09 00:12:09 +0200
committerMarc Cornellà <marc.cornella@live.com>2019-06-09 16:33:06 +0200
commit702a594df3b49f40496e4840cae2d93c83d5bc4d (patch)
tree6ba884dc61171f495444bd30b39101886511c44a
parentd69bad8eb4157e5fd5c1a4ce98f93cf522477a8c (diff)
downloadzsh-702a594df3b49f40496e4840cae2d93c83d5bc4d.tar.gz
zsh-702a594df3b49f40496e4840cae2d93c83d5bc4d.tar.bz2
zsh-702a594df3b49f40496e4840cae2d93c83d5bc4d.zip
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.
-rwxr-xr-xtools/install.sh21
1 files changed, 9 insertions, 12 deletions
diff --git a/tools/install.sh b/tools/install.sh
index d56d8addc..17b70bfea 100755
--- a/tools/install.sh
+++ b/tools/install.sh
@@ -50,25 +50,22 @@ error() {
echo ${RED}"Error: $@"${RESET} >&2
}
-# Set up color sequences
setup_color() {
- ncolors=$(tput colors 2>/dev/null) || ncolors=0
-
- # Only use colors if connected to a terminal that supports them
- if [ -t 1 ] && [ $ncolors -ge 8 ]; then
- RED="$(tput setaf 1)"
- GREEN="$(tput setaf 2)"
- YELLOW="$(tput setaf 3)"
- BLUE="$(tput setaf 4)"
- BOLD="$(tput bold)"
- RESET="$(tput sgr0)"
- else
+ # Only use colors if connected to a terminal
+ if [ -t 1 ]; then
RED=$(printf '\033[31m')
GREEN=$(printf '\033[32m')
YELLOW=$(printf '\033[33m')
BLUE=$(printf '\033[34m')
BOLD=$(printf '\033[1m')
RESET=$(printf '\033[m')
+ else
+ RED=""
+ GREEN=""
+ YELLOW=""
+ BLUE=""
+ BOLD=""
+ RESET=""
fi
}