[ruby/irb] Let IRB::Color.colorable? always return true|false

(https://github.com/ruby/irb/pull/940)

https://github.com/ruby/irb/commit/0bbe435ffe
This commit is contained in:
tomoya ishida 2024-05-01 23:52:49 +09:00 committed by git
parent 1000c27db8
commit 77f5301cd1

View File

@ -79,12 +79,12 @@ module IRB # :nodoc:
class << self
def colorable?
supported = $stdout.tty? && (/mswin|mingw/ =~ RUBY_PLATFORM || (ENV.key?('TERM') && ENV['TERM'] != 'dumb'))
supported = $stdout.tty? && (/mswin|mingw/.match?(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)
supported && !!IRB.conf.fetch(:USE_COLORIZE, true)
else
supported
end