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.)
This commit is contained in:
Avery Pennarun 2011-01-04 14:11:29 -08:00
commit f6ea1fd76b
2 changed files with 2 additions and 2 deletions

2
log.py
View file

@ -8,7 +8,7 @@ YELLOW = ""
BOLD = "" BOLD = ""
PLAIN = "" PLAIN = ""
if sys.stderr.isatty(): if sys.stderr.isatty() and (os.environ.get('TERM') or 'dumb') != 'dumb':
# ...use ANSI formatting codes. # ...use ANSI formatting codes.
RED = "\x1b[31m" RED = "\x1b[31m"
GREEN = "\x1b[32m" GREEN = "\x1b[32m"

View file

@ -12,7 +12,7 @@ GREEN=""
BOLD="" BOLD=""
PLAIN="" 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')" GREEN="$(printf '\033[32m')"
BOLD="$(printf '\033[1m')" BOLD="$(printf '\033[1m')"
PLAIN="$(printf '\033[m')" PLAIN="$(printf '\033[m')"