summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorst0012 <stan001212@gmail.com>2022-06-28 14:47:28 +0100
committergit <svn-admin@ruby-lang.org>2022-06-28 22:57:17 +0900
commit7d211c93af2253c5f5a4eb988a362f3220965980 (patch)
tree1557538548ee5e2b0cde147a367b1e00bff07b66
parent44c1316293f80abaa0e76b3818322544b9372a97 (diff)
[ruby/irb] Color.colorable? needs to consider the condition when irb is not loaded
ruby/debug uses `irb/color` selectively: https://github.com/ruby/debug/blob/0ac22406bb8f65bc76f9f5576a00c729cac693af/lib/debug/color.rb#L4 And in that case, `IRB.conf` won't be defined. So Color.colorable? needs to consider that. This also fixes the Ruby trunk CI. https://github.com/ruby/irb/commit/b2cd07e795
-rw-r--r--lib/irb/color.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/irb/color.rb b/lib/irb/color.rb
index c4513f5b0b..8307af25a9 100644
--- a/lib/irb/color.rb
+++ b/lib/irb/color.rb
@@ -77,7 +77,15 @@ module IRB # :nodoc:
class << self
def colorable?
- $stdout.tty? && (/mswin|mingw/ =~ RUBY_PLATFORM || (ENV.key?('TERM') && ENV['TERM'] != 'dumb')) && IRB.conf.fetch(:USE_COLORIZE, true)
+ supported = $stdout.tty? && (/mswin|mingw/ =~ RUBY_PLATFORM || (ENV.key?('TERM') && ENV['TERM'] != 'dumb'))
+
+ # because ruby/debug also uses irb's color module selectively,
+ # irb won't be activated in that case.
+ if IRB.respond_to?(:conf)
+ supported && IRB.conf.fetch(:USE_COLORIZE, true)
+ else
+ supported
+ end
end
def inspect_colorable?(obj, seen: {}.compare_by_identity)