tools/install: Add support termcap-based tput

This commit is contained in:
Koichi Murase
2021-04-20 11:43:23 +09:00
parent 5984c17d14
commit 39c9598081

View File

@ -3,16 +3,16 @@
main() { main() {
# Use colors, but only if connected to a terminal, and that terminal # Use colors, but only if connected to a terminal, and that terminal
# supports them. # supports them.
if which tput >/dev/null 2>&1; then if hash tput >/dev/null 2>&1; then
ncolors=$(tput colors) ncolors=$(tput colors 2>/dev/null || tput Co 2>/dev/null || echo -1)
fi fi
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
RED="$(tput setaf 1)" RED=$(tput setaf 1 2>/dev/null || tput AF 1 2>/dev/null)
GREEN="$(tput setaf 2)" GREEN=$(tput setaf 2 2>/dev/null || tput AF 2 2>/dev/null)
YELLOW="$(tput setaf 3)" YELLOW=$(tput setaf 3 2>/dev/null || tput AF 3 2>/dev/null)
BLUE="$(tput setaf 4)" BLUE=$(tput setaf 4 2>/dev/null || tput AF 4 2>/dev/null)
BOLD="$(tput bold)" BOLD=$(tput bold 2>/dev/null || tput md 2>/dev/null)
NORMAL="$(tput sgr0)" NORMAL=$(tput sgr0 2>/dev/null || tput me 2>/dev/null)
else else
RED="" RED=""
GREEN="" GREEN=""