Skip to content

Commit

Permalink
Suppress error in case INPUTRC env is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
aycabta committed Mar 21, 2020
1 parent a6148e6 commit bce7e75
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/reline/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/reline/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit bce7e75

Please sign in to comment.