summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md9
-rw-r--r--lib/irb/init.rb2
-rw-r--r--test/irb/test_init.rb24
3 files changed, 34 insertions, 1 deletions
diff --git a/README.md b/README.md
index 35ef2d9e89..c17b901728 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,15 @@ see [Building Ruby](doc/contributing/building_ruby.md)
https://www.ruby-lang.org/
+## Configuration
+
+### Environment Variables
+
+- `NO_COLOR`: Assigning a value to it disables IRB's colorization.
+- `IRB_USE_AUTOCOMPLETE`: Setting it to `false` disables IRB's autocompletion.
+- `EDITOR`: Its value would be used to open files by the `edit` command.
+- `IRBRC`: The file specified would be evaluated as IRB's rc-file.
+
## Documentation
- [English](https://docs.ruby-lang.org/en/master/index.html)
diff --git a/lib/irb/init.rb b/lib/irb/init.rb
index dd888f3727..55453cc8f7 100644
--- a/lib/irb/init.rb
+++ b/lib/irb/init.rb
@@ -45,7 +45,7 @@ module IRB # :nodoc:
@CONF[:USE_SINGLELINE] = false unless defined?(ReadlineInputMethod)
@CONF[:USE_COLORIZE] = (nc = ENV['NO_COLOR']).nil? || nc.empty?
- @CONF[:USE_AUTOCOMPLETE] = true
+ @CONF[:USE_AUTOCOMPLETE] = ENV.fetch("IRB_USE_AUTOCOMPLETE", "true") != "false"
@CONF[:INSPECT_MODE] = true
@CONF[:USE_TRACER] = false
@CONF[:USE_LOADER] = false
diff --git a/test/irb/test_init.rb b/test/irb/test_init.rb
index 9591de1589..d9e338da8d 100644
--- a/test/irb/test_init.rb
+++ b/test/irb/test_init.rb
@@ -96,6 +96,30 @@ module TestIRB
IRB.conf[:USE_COLORIZE] = orig_use_colorize
end
+ def test_use_autocomplete_environment_variable
+ orig_use_autocomplete_env = ENV['IRB_USE_AUTOCOMPLETE']
+ orig_use_autocomplete_conf = IRB.conf[:USE_AUTOCOMPLETE]
+
+ ENV['IRB_USE_AUTOCOMPLETE'] = nil
+ IRB.setup(__FILE__)
+ assert IRB.conf[:USE_AUTOCOMPLETE]
+
+ ENV['IRB_USE_AUTOCOMPLETE'] = ''
+ IRB.setup(__FILE__)
+ assert IRB.conf[:USE_AUTOCOMPLETE]
+
+ ENV['IRB_USE_AUTOCOMPLETE'] = 'false'
+ IRB.setup(__FILE__)
+ refute IRB.conf[:USE_AUTOCOMPLETE]
+
+ ENV['IRB_USE_AUTOCOMPLETE'] = 'true'
+ IRB.setup(__FILE__)
+ assert IRB.conf[:USE_AUTOCOMPLETE]
+ ensure
+ ENV["IRB_USE_AUTOCOMPLETE"] = orig_use_autocomplete_env
+ IRB.conf[:USE_AUTOCOMPLETE] = orig_use_autocomplete_conf
+ end
+
def test_noscript
argv = %w[--noscript -- -f]
IRB.setup(eval("__FILE__"), argv: argv)