summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraycabta <aycabta@gmail.com>2021-07-24 15:01:22 +0900
committeraycabta <aycabta@gmail.com>2021-07-30 02:27:02 +0900
commit46c6da9c378a64deb2d65d8fcf5afd4d7c9c3f45 (patch)
treeb74d1ae9b2e93224b6138218da0e1fa52029997d
parent51ee24e7f7223b5c759eebcd9fe12d7f16ea6707 (diff)
[ruby/reline] Check empty .inputrc
https://github.com/ruby/reline/commit/b60b3b76cd
-rw-r--r--lib/reline/config.rb2
-rw-r--r--test/reline/test_config.rb6
2 files changed, 7 insertions, 1 deletions
diff --git a/lib/reline/config.rb b/lib/reline/config.rb
index 3e6c42df48..c2b50a95a2 100644
--- a/lib/reline/config.rb
+++ b/lib/reline/config.rb
@@ -158,7 +158,7 @@ class Reline::Config
end
def read_lines(lines, file = nil)
- if lines.first.encoding != Reline.encoding_system_needs
+ if not lines.empty? and lines.first.encoding != Reline.encoding_system_needs
begin
lines = lines.map do |l|
l.encode(Reline.encoding_system_needs)
diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb
index b6d2ec7d7e..aa549a392d 100644
--- a/test/reline/test_config.rb
+++ b/test/reline/test_config.rb
@@ -311,6 +311,12 @@ class Reline::Config::Test < Reline::TestCase
# do nothing
end
+ def test_empty_inputrc
+ assert_nothing_raised do
+ @config.read_lines([])
+ end
+ end
+
def test_xdg_config_home
home_backup = ENV['HOME']
xdg_config_home_backup = ENV['XDG_CONFIG_HOME']