summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvery Pennarun <apenwarr@gmail.com>2011-01-04 14:11:29 -0800
committerAvery Pennarun <apenwarr@gmail.com>2011-01-04 14:11:29 -0800
commitf6ea1fd76b21d71672243c1bf5e139034dbf9120 (patch)
tree168c64761d86d70cce0e1bd7769f35d2cb0f2f2e
parentcb1512b14b8c7ee6f29dc7b9be57dbb582cda2cd (diff)
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.)
-rw-r--r--log.py2
-rwxr-xr-xminimal/do2
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')"