diff --git a/tools/install.sh b/tools/install.sh index 187c828f..7fb6c70b 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -1,10 +1,15 @@ -main() { - # Use colors, but only if connected to a terminal, and that terminal - # supports them. +#!/bin/sh + +# Set up color sequences +setup_color() { if which tput >/dev/null 2>&1; then - ncolors=$(tput colors) + ncolors=$(tput colors) + else + ncolors=0 fi - if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then + + # 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)" @@ -19,6 +24,10 @@ main() { BOLD="" NORMAL="" fi +} + +main() { + setup_color # Only enable exit-on-error after the non-critical colorization stuff, # which may fail on systems lacking tput or terminfo