Only use colored output if the terminal supports it

This also removes all the tput noise we are seeing in buildbot logs.
("tput: No value for $TERM and no -T specified", "tput: unknown terminal
"unknown", etc.)

BUG=none
TEST=manual below
src/platform/scripts$ TERM=unknown; ./enter_chroot (No more tput errors)

Change-Id: Ic74a0bd66d7e0cedcf7b65ec3a5f43b61b8276f9
Reviewed-on: http://gerrit.chromium.org/gerrit/4763
Tested-by: Gaurav Shah <gauravsh@chromium.org>
Reviewed-by: Richard Barnette <jrbarnette@chromium.org>
This commit is contained in:
Gaurav Shah 2011-07-26 15:03:37 -07:00
parent 0fffd2bc75
commit 786ceeb389

View File

@ -218,11 +218,20 @@ FACTORY_INSTALL_MASK="
/usr/share/zoneinfo
"
V_REVERSE="$(tput rev)"
V_VIDOFF="$(tput sgr0)"
V_BOLD_RED="$(tput bold; tput setaf 1)"
V_BOLD_GREEN="$(tput bold; tput setaf 2)"
V_BOLD_YELLOW="$(tput bold; tput setaf 3)"
# Determine and set up variables needed for fancy color output (if supported).
V_REVERSE=
V_VIDOFF=
V_BOLD_RED=
V_BOLD_GREEN=
V_BOLD_YELLOW=
if tput colors >/dev/null 2>&1; then
V_REVERSE="$(tput rev)"
V_VIDOFF="$(tput sgr0)"
V_BOLD_RED="$(tput bold; tput setaf 1)"
V_BOLD_GREEN="$(tput bold; tput setaf 2)"
V_BOLD_YELLOW="$(tput bold; tput setaf 3)"
fi
# -----------------------------------------------------------------------------
# Functions