diff --git a/lib/irb/init.rb b/lib/irb/init.rb index 78ef2fa3c1..3a5f3de26c 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -44,7 +44,7 @@ module IRB # :nodoc: @CONF[:IRB_RC] = nil @CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod) - @CONF[:USE_COLORIZE] = true + @CONF[:USE_COLORIZE] = !ENV['NO_COLOR'] @CONF[:INSPECT_MODE] = true @CONF[:USE_TRACER] = false @CONF[:USE_LOADER] = false @@ -301,11 +301,11 @@ module IRB # :nodoc: break end end + load_path.collect! do |path| /\A\.\// =~ path ? path : File.expand_path(path) end $LOAD_PATH.unshift(*load_path) - end # running config diff --git a/test/irb/test_init.rb b/test/irb/test_init.rb index d57f0752bb..ade2fcb392 100644 --- a/test/irb/test_init.rb +++ b/test/irb/test_init.rb @@ -67,6 +67,22 @@ module TestIRB Process.kill("SIGKILL", status.pid) if !status.exited? && !status.stopped? && !status.signaled? end + def test_no_color_environment_variable + orig = ENV['NO_COLOR'] + + assert IRB.conf[:USE_COLORIZE] + + ENV['NO_COLOR'] = 'true' + IRB.setup(eval("__FILE__")) + refute IRB.conf[:USE_COLORIZE] + + ENV['NO_COLOR'] = nil + IRB.setup(eval("__FILE__")) + assert IRB.conf[:USE_COLORIZE] + ensure + ENV['NO_COLOR'] = orig + end + private def with_argv(argv)