if [[ "$o_nocolor" != "true" && -n "$1" ]]; then
export TERM=$ORIGINAL_TERM
case "$1" in
- error) tput bold; tput setaf 1;;
- skip) tput setaf 5;;
+ error) tput $C_BOLD; tput $C_SETAF 1;;
+ skip) tput $C_SETAF 5;;
ok)
(($o_verbose == 0)) && return
- tput setaf 2;;
- pass) tput bold; tput setaf 2;;
- info) tput setaf 3;;
+ tput $C_SETAF 2;;
+ pass) tput $C_BOLD; tput $C_SETAF 2;;
+ info) tput $C_SETAF 3;;
run)
(($o_verbose == 0)) && return
- tput setaf 6;;
+ tput $C_SETAF 6;;
esac
fi
shift
printf "%s\n" "$*"
if [[ "$o_nocolor" != "true" && -n "$1" ]]; then
- tput sgr0
+ tput $C_SGR0
export TERM=dumb
fi
}
result="false"
[[ "$TERM" == "dumb" ]] && return
[[ -t 1 ]] || return
- tput bold >/dev/null 2>&1 || return
- tput setaf 1 >/dev/null 2>&1 || return
- tput sgr0 >/dev/null 2>&1 || return
+ C_BOLD='bold'
+ tput $C_BOLD &>/dev/null || {
+ C_BOLD='md'
+ tput $C_BOLD &>/dev/null
+ } || return
+ C_SETAF='setaf'
+ tput $C_SETAF 1 &>/dev/null || {
+ C_SETAF='AF'
+ tput $C_SETAF 1 &>/dev/null
+ } || return
+ C_SGR0='sgr0'
+ tput $C_SGR0 >/dev/null 2>&1 || {
+ C_SGR0='me'
+ tput $C_SGR0 &>/dev/null
+ } || return
result="true"
}