Skip to content

Commit bce7e75

Browse files
committed
Suppress error in case INPUTRC env is empty
1 parent a6148e6 commit bce7e75

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

lib/reline/config.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,17 @@ def keymap
8383
@key_actors[@keymap_label]
8484
end
8585

86+
def inputrc_path
87+
case ENV['INPUTRC']
88+
when nil, ''
89+
DEFAULT_PATH
90+
else
91+
ENV['INPUTRC']
92+
end
93+
end
94+
8695
def read(file = nil)
87-
file ||= File.expand_path(ENV['INPUTRC'] || DEFAULT_PATH)
96+
file ||= File.expand_path(inputrc_path)
8897
begin
8998
if file.respond_to?(:readlines)
9099
lines = file.readlines

test/reline/test_config.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,4 +206,13 @@ def test_history_size
206206
history << "a\n"
207207
assert_equal 1, history.size
208208
end
209+
210+
def test_empty_inputrc_env
211+
inputrc_backup = ENV['INPUTRC']
212+
ENV['INPUTRC'] = ''
213+
assert_nothing_raised do
214+
@config.read
215+
end
216+
ENV['INPUTRC'] = inputrc_backup
217+
end
209218
end

0 commit comments

Comments
 (0)