File tree Expand file tree Collapse file tree 2 files changed +18
-2
lines changed
Expand file tree Collapse file tree 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ def IRB.init_config(ap_path)
4444 @CONF [ :IRB_RC ] = nil
4545
4646 @CONF [ :USE_SINGLELINE ] = false unless defined? ( ReadlineInputMethod )
47- @CONF [ :USE_COLORIZE ] = true
47+ @CONF [ :USE_COLORIZE ] = ! ENV [ 'NO_COLOR' ]
4848 @CONF [ :INSPECT_MODE ] = true
4949 @CONF [ :USE_TRACER ] = false
5050 @CONF [ :USE_LOADER ] = false
@@ -224,11 +224,11 @@ def IRB.parse_opts(argv: ::ARGV)
224224 break
225225 end
226226 end
227+
227228 load_path . collect! do |path |
228229 /\A \. \/ / =~ path ? path : File . expand_path ( path )
229230 end
230231 $LOAD_PATH. unshift ( *load_path )
231-
232232 end
233233
234234 # running config
Original file line number Diff line number Diff line change @@ -60,6 +60,22 @@ def test_rc_file_in_subdir
6060 ENV [ "IRBRC" ] = backup_irbrc
6161 end
6262
63+ def test_no_color_environment_variable
64+ orig = ENV [ 'NO_COLOR' ]
65+
66+ assert IRB . conf [ :USE_COLORIZE ]
67+
68+ ENV [ 'NO_COLOR' ] = 'true'
69+ IRB . setup ( eval ( "__FILE__" ) )
70+ refute IRB . conf [ :USE_COLORIZE ]
71+
72+ ENV [ 'NO_COLOR' ] = nil
73+ IRB . setup ( eval ( "__FILE__" ) )
74+ assert IRB . conf [ :USE_COLORIZE ]
75+ ensure
76+ ENV [ 'NO_COLOR' ] = orig
77+ end
78+
6379 private
6480
6581 def with_argv ( argv )
You can’t perform that action at this time.
0 commit comments