From f6ea1fd76b21d71672243c1bf5e139034dbf9120 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Tue, 4 Jan 2011 14:11:29 -0800 Subject: [PATCH] log.py, minimal/do: don't use ansi colour codes if $TERM is blank or 'dumb' Apparently emacs sets TERM=dumb in its tty simulator, so even though isatty() returns true, we shouldn't use colour codes. (emacs is therefore lame. But we knew that.) --- log.py | 2 +- minimal/do | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/log.py b/log.py index c217e7e..47ea6cb 100644 --- a/log.py +++ b/log.py @@ -8,7 +8,7 @@ YELLOW = "" BOLD = "" PLAIN = "" -if sys.stderr.isatty(): +if sys.stderr.isatty() and (os.environ.get('TERM') or 'dumb') != 'dumb': # ...use ANSI formatting codes. RED = "\x1b[31m" GREEN = "\x1b[32m" diff --git a/minimal/do b/minimal/do index e4b02ae..1d3c94a 100755 --- a/minimal/do +++ b/minimal/do @@ -12,7 +12,7 @@ GREEN="" BOLD="" PLAIN="" -if tty <&2 >/dev/null 2>&1; then +if [ -n "$TERM" -a "$TERM" != "dumb" ] && tty <&2 >/dev/null 2>&1; then GREEN="$(printf '\033[32m')" BOLD="$(printf '\033[1m')" PLAIN="$(printf '\033[m')"