Skip to content

Commit 4d8a085

Browse files
committed
Fix to test a command before trying just in case
1 parent 9693c99 commit 4d8a085

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

slib.sh

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,18 @@ fi
6161
# canonical source http://github.com/swelljoe/scolors
6262

6363
# Check if terminal is supported and set TERM to a supported one if not
64-
is_term_supported() {
64+
is_term_supported () {
6565
term=$1
6666
[ -n "$term" ] || term=dumb # avoid empty TERM
67-
tput -T "$term" cols >/dev/null 2>&1 # any capability is enough
67+
# Tput probe
68+
if command -pv tput >/dev/null 2>&1; then
69+
tput -T "$term" cols >/dev/null 2>&1 && return 0 || return 1
70+
fi
71+
# Infocmp probe
72+
if command -pv infocmp >/dev/null 2>&1; then
73+
infocmp "$term" >/dev/null 2>&1 && return 0 || return 1
74+
fi
75+
return 1
6876
}
6977
FALLBACK_TERMS='xterm-256color xterm-color xterm vt220 ansi dumb'
7078
if ! is_term_supported "$TERM"; then

0 commit comments

Comments
 (0)