1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

[ruby/reline] Suppress error in case INPUTRC env is empty

https://github.com/ruby/reline/commit/bce7e7562b
This commit is contained in:
aycabta 2020-03-21 18:13:50 +09:00
parent f245fb1ab8
commit 90913bfabe
2 changed files with 19 additions and 1 deletions

View file

@ -83,8 +83,17 @@ class Reline::Config
@key_actors[@keymap_label]
end
def inputrc_path
case ENV['INPUTRC']
when nil, ''
DEFAULT_PATH
else
ENV['INPUTRC']
end
end
def read(file = nil)
file ||= File.expand_path(ENV['INPUTRC'] || DEFAULT_PATH)
file ||= File.expand_path(inputrc_path)
begin
if file.respond_to?(:readlines)
lines = file.readlines

View file

@ -206,4 +206,13 @@ class Reline::Config::Test < Reline::TestCase
history << "a\n"
assert_equal 1, history.size
end
def test_empty_inputrc_env
inputrc_backup = ENV['INPUTRC']
ENV['INPUTRC'] = ''
assert_nothing_raised do
@config.read
end
ENV['INPUTRC'] = inputrc_backup
end
end