зеркало из https://github.com/github/ruby.git
[ruby/reline] Suppress error in case INPUTRC env is empty
https://github.com/ruby/reline/commit/bce7e7562b
This commit is contained in:
Родитель
f245fb1ab8
Коммит
90913bfabe
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче