diff --git a/lib/irb/init.rb b/lib/irb/init.rb index da40bee5e..569b199e1 100644 --- a/lib/irb/init.rb +++ b/lib/irb/init.rb @@ -44,7 +44,7 @@ def IRB.init_config(ap_path) @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 @@ -224,11 +224,11 @@ def IRB.parse_opts(argv: ::ARGV) 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 b51d01096..6fa287579 100644 --- a/test/irb/test_init.rb +++ b/test/irb/test_init.rb @@ -60,6 +60,22 @@ def test_rc_file_in_subdir ENV["IRBRC"] = backup_irbrc end + def test_no_color_environment_variable + orig = ENV['NO_COLOR'] + + assert IRB.conf[:USE_COLORIZE] + + ENV['NO_COLOR'] = 'true' + IRB.setup(__FILE__) + refute IRB.conf[:USE_COLORIZE] + + ENV['NO_COLOR'] = nil + IRB.setup(__FILE__) + assert IRB.conf[:USE_COLORIZE] + ensure + ENV['NO_COLOR'] = orig + end + private def with_argv(argv)