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:
parent
f245fb1ab8
commit
90913bfabe
2 changed files with 19 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue