summaryrefslogtreecommitdiff
path: root/build-aux/check.mk
diff options
context:
space:
mode:
authorBob Proulx <bob@proulx.com>2007-10-29 05:10:23 -0600
committerBob Proulx <bob@proulx.com>2007-10-29 05:10:23 -0600
commitb8e8d028613e9394dbce80d32c1c1bbdeb330776 (patch)
treeef5ffc8808b4e8d419b794dc0cafb6603f288b57 /build-aux/check.mk
parentb63b1b4ce2612960f785670481ff3a9fa68c4bd3 (diff)
downloadcoreutils-b8e8d028613e9394dbce80d32c1c1bbdeb330776.tar.xz
Improve color terminal escape usage.
* build-aux/check.mk (am__tty_colors): Use 'tput' to deduce terminal color capabilities.
Diffstat (limited to 'build-aux/check.mk')
-rw-r--r--build-aux/check.mk36
1 files changed, 20 insertions, 16 deletions
diff --git a/build-aux/check.mk b/build-aux/check.mk
index 862b3e52b..fd6fb2b8d 100644
--- a/build-aux/check.mk
+++ b/build-aux/check.mk
@@ -56,23 +56,27 @@ END { \
print line; \
}'
-# If stdout is a tty, use colors. If test -t is not supported, then
-# this fails; a conservative approach. Of course do not redirect
-# stdout here, just stderr...
+# If stdout is a tty and TERM is smart then use colors. If test -t or
+# tput are not supported then this fails; a conservative approach. Of
+# course do not redirect stdout here, just stderr...
am__tty_colors = \
-if test -t 1 2>/dev/null && test -n "$$TERM" && test "$$TERM" != dumb; then \
- red=''; \
- grn=''; \
- lgn=''; \
- blu=''; \
- std=''; \
-else \
- red=; \
- grn=; \
- lgn=; \
- blu=; \
- std=; \
-fi
+red=; \
+grn=; \
+lgn=; \
+blu=; \
+std=; \
+test "X$$TERM" != Xdumb && \
+test -t 1 2>/dev/null && \
+tput bold 1 >/dev/null 2>&1 && \
+tput setaf 1 >/dev/null 2>&1 && \
+tput sgr0 >/dev/null 2>&1 && \
+{ \
+ red=$$(tput setaf 1); \
+ grn=$$(tput setaf 2); \
+ lgn=$$(tput bold)$$(tput setaf 2); \
+ blu=$$(tput setaf 4); \
+ std=$$(tput sgr0); \
+}
# To be inserted before the command running the test. Creates the
# directory for the log if needed. Stores in $dir the directory