[前][次][番号順一覧][スレッド一覧]

ruby-changes:66702

From: Nobuyoshi <ko1@a...>
Date: Tue, 6 Jul 2021 21:03:21 +0900 (JST)
Subject: [ruby-changes:66702] afd4cfcf22 (master): Try "so" attribute if "smso" is not found

https://git.ruby-lang.org/ruby.git/commit/?id=afd4cfcf22

From afd4cfcf22a4ec6e2dbd5f774169ce771d22acea Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Tue, 6 Jul 2021 19:06:49 +0900
Subject: Try "so" attribute if "smso" is not found

---
 tool/lib/colorize.rb                | 2 +-
 tool/m4/_colorize_result_prepare.m4 | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/tool/lib/colorize.rb b/tool/lib/colorize.rb
index 6699aef..11b878d 100644
--- a/tool/lib/colorize.rb
+++ b/tool/lib/colorize.rb
@@ -8,7 +8,7 @@ class Colorize https://github.com/ruby/ruby/blob/trunk/tool/lib/colorize.rb#L8
     @colors = @reset = nil
     @color = (opts[:color] if opts)
     if color or (color == nil && STDOUT.tty?)
-      if (/\A\e\[.*m\z/ =~ IO.popen("tput smso", "r", :err => IO::NULL, &:read) rescue nil)
+      if (%w[smso so].any? {|attr| /\A\e\[.*m\z/ =~ IO.popen("tput #{attr}", "r", :err => IO::NULL, &:read)} rescue nil)
         @beg = "\e["
         colors = (colors = ENV['TEST_COLORS']) ? Hash[colors.scan(/(\w+)=([^:\n]*)/)] : {}
         if opts and colors_file = opts[:colors_file]
diff --git a/tool/m4/_colorize_result_prepare.m4 b/tool/m4/_colorize_result_prepare.m4
index c8478bd..8439acf 100644
--- a/tool/m4/_colorize_result_prepare.m4
+++ b/tool/m4/_colorize_result_prepare.m4
@@ -9,6 +9,7 @@ AC_DEFUN([_COLORIZE_RESULT_PREPARE], [ https://github.com/ruby/ruby/blob/trunk/tool/m4/_colorize_result_prepare.m4#L9
                        [configure_tty=0])])
     AS_IF([test $configure_tty -eq 1], [
 	msg_begin="`tput smso 2>/dev/null`"
+	AS_IF([test -z "$msg_begin"], [msg_begin="`tput so 2>/dev/null`"])
 	AS_CASE(["$msg_begin"], ['@<:@'*m],
 	    [msg_begin="`echo "$msg_begin" | sed ['s/[0-9]*m$//']`"
 	    msg_checking="${msg_begin}33m"
-- 
cgit v1.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]