aboutsummaryrefslogtreecommitdiffstats
path: root/tool/ifchange
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-22 14:02:38 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-10-22 14:02:38 +0000
commitf1a66687d243878e2518b140dd65907398794820 (patch)
treebdb2d7d68d7e74564142188ba22947e419274e2b /tool/ifchange
parent879e1420592cb8f6fee7cc0be336b8506ad63a6e (diff)
downloadruby-f1a66687d243878e2518b140dd65907398794820.tar.gz
colorize
* tool/generic_erb.rb: use VT100 sequence if tput does not work. * tool/ifchange: ditto and add --color option. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52220 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/ifchange')
-rwxr-xr-xtool/ifchange16
1 files changed, 11 insertions, 5 deletions
diff --git a/tool/ifchange b/tool/ifchange
index 7d7b377be7..4164572b76 100755
--- a/tool/ifchange
+++ b/tool/ifchange
@@ -5,6 +5,7 @@ set -e
timestamp=
keepsuffix=
empty=
+color=auto
until [ $# -eq 0 ]; do
case "$1" in
--timestamp)
@@ -22,6 +23,12 @@ until [ $# -eq 0 ]; do
--empty)
empty=yes
;;
+ --color)
+ color=always
+ ;;
+ --color=*)
+ color=`expr \( "$1" : '[^=]*=\(.*\)' \)`
+ ;;
*)
break
;;
@@ -38,11 +45,10 @@ if [ "$temp" = - ]; then
fi
msg_begin= msg_unchanged= msg_updated= msg_reset=
-if [ -t 1 ]; then
- msg_begin="`tput smso 2>/dev/null`" || :
- case "$msg_begin" in
- ""*m)
- msg_begin="`echo "$msg_begin" | sed 's/[0-9]*m$//'`"
+if [ "$color" = always -o \( "$color" = auto -a -t 1 \) ]; then
+ msg_begin="["
+ case "`tput smso 2>/dev/null`" in
+ "$msg_begin"*m|"")
if [ ${TEST_COLORS:+set} ]; then
msg_unchanged=`expr ":$TEST_COLORS:" : ".*:pass=\([^:]*\):"`
msg_updated=`expr ":$TEST_COLORS:" : ".*:fail=\([^:]*\):"`