diff --git a/lib/reline/config.rb b/lib/reline/config.rb index 61708f96a7..53b868fd2e 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -83,8 +83,17 @@ def keymap @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 diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb index 14342fff86..cecb364f89 100644 --- a/test/reline/test_config.rb +++ b/test/reline/test_config.rb @@ -206,4 +206,13 @@ def test_history_size 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