FS#7369 - rc scripts should check the $TERM variable and disable color on "dumb" terminals
Attached to Project:
Arch Linux
Opened by Arthur Danskin (wiremore) - Tuesday, 05 June 2007, 19:07 GMT
Last edited by Tobias Powalowski (tpowa) - Thursday, 25 October 2007, 05:42 GMT
Opened by Arthur Danskin (wiremore) - Tuesday, 05 June 2007, 19:07 GMT
Last edited by Tobias Powalowski (tpowa) - Thursday, 25 October 2007, 05:42 GMT
|
Details
It's nice to have colored rc script output, but I often use
the emacs shell, which does not support escape characters.
In this case, it would be nice if the rc scripts
automatically disabled color. This can be easily implemented
by changing the line:
if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" ]; then to: if [ "$USECOLOR" = "YES" -o "$USECOLOR" = "yes" -a "$TERM" != "dumb" ]; then in /etc/rc.d/functions |
This task depends upon
Closed by Tobias Powalowski (tpowa)
Thursday, 25 October 2007, 05:42 GMT
Reason for closing: Fixed
Additional comments about closing: latest initscripts
Thursday, 25 October 2007, 05:42 GMT
Reason for closing: Fixed
Additional comments about closing: latest initscripts
I agree that colour should be disabled on terms that don't support it though, even if USECOLOR is yes.
This might work:
$(tput colors) -ge 8
In place of the explicit $TERM check
$ tput colors
8
$ echo $TERM
rxvt
$ TERM=dumb tput colors
-1
$
For example, trying to query color support for a terminal which doesn't have a terminfo entry results in tput printing a string `tput: unknown terminal "X"' instead of printing `-1' for no colors.
if [[ ( $USECOLOR = yes || $USECOLOR = YES ) && `tput colors` > 7 ]] 2>/dev/null; then
Note the usage of `[[' and `>' here. It looks pretty crappy, but that's all I could think of.
Apply this patch to rc.sysinit and try again. Sorry for my stupidness on that one.
You might want to use [[ instead of [ here, as [[ accepts empty strings as operands for -lt.
if [ -n "${TERM_COLORS}" ]; then
is for. The left operand in line 30 can never be empty.
Now it's all right.