Skip to content

Conversation

@jengelh
Copy link
Contributor

@jengelh jengelh commented Dec 29, 2025

It is possible for test "$(tput colors)" -ge 8 to throw a -bash: test: : integer expected exception.

In commit 983fd43, tput colors was always followed by || echo 0, because tput does not output anything if there are no definitions for the current $TERM value. This got lost in commit 5486aad.

In commit 983fd43, `tput colors` was
always followed by `|| echo 0`, because tput does not output anything
if there are no definitions for the current $TERM value.
This got lost in commit 5486aad.
@bitstreamout
Copy link
Member

Umm .. this should be working with latest ncurses again ... means tput colors should show -1 ....

TERM=vt100 tput colors
-1

on all architectures ...at least the latest %check of ncurses does test this an all architectures

@bugfinder
Copy link
Member

so this change is obsoleted ?

@bitstreamout
Copy link
Member

Looks like Jürgen is still on vacation

so this change is obsoleted ?

@jengelh
Copy link
Contributor Author

jengelh commented Jan 9, 2026

tput does not always output -1.

$ TERM="" tput colors
[stderr] tput: No value for $TERM and no -T specified

@bitstreamout
Copy link
Member

tput does not always output -1.

$ TERM="" tput colors
[stderr] tput: No value for $TERM and no -T specified

AFAICS in /usr/etc/profile.d/alias.bash there is:

if type -p tput >/dev/null 2>&1 && test -n "$TERM" -a -t 1 && test "$(tput colors)" -ge 8 ; then

as well as in /usr/etc/profile.d/alias.tcsh

if ( -X tput && ${?TERM} && -t 1 ) then
    if ( `tput colors` >= 8 ) then

where tput can fetch an empty or not set $TERM ... in tcsh code but not in bash code or do I overread something?

@bitstreamout
Copy link
Member

A wrong set TERM indeed

(setenv TERM foobar; tput colors)
tcsh: using dumb terminal settings.
tput: unknown terminal "foobar"

@bitstreamout
Copy link
Member

The special longname of tput could be used to check ...

bash code:

tput longname > /dev/null 2>&1 && tput colors

tcsh code:

tput longname >& /dev/null && tput colors

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants