Comment 32 for bug 103929

Revision history for this message
Micah Cowan (micahcowan) wrote :

"tput setaf" is the appropriate check to use, and was already present in my initial recommendation (via the first comment to this report), and in fact is what's currently being used (at least in Lucid) in /etc/skel/.bashrc (if force_color_prompt is set).

There's no way to do an echo/check stdout test as you suggest. It's the terminal itself that prevents the garbling, and there's no portable way to check whether a final output string was garbled or not, since there's no portable way to inspect the display contents on a terminal (AFAIK, for most terminals there's not even an unportable way).

Note that the difference between "xterm" and "xterm-color" has never been the difference between color support and no color support; it was intended to convey the difference between basic color support and extended (256) color support. That's why I thought it was silly to check for "xterm-color", but then only make use of basic colors that would work on "xterm" (no "-color") anyway. We still do that if force_color_prompt isn't set, and I still think it's silly (but then, I also think it's silly that gnome-terminal doesn't set TERM to xterm-color, since gnome-terminal does in fact support extended colors).