ruby-changes:60508
From: aycabta <ko1@a...>
Date: Thu, 26 Mar 2020 17:44:31 +0900 (JST)
Subject: [ruby-changes:60508] 90913bfabe (master): [ruby/reline] Suppress error in case INPUTRC env is empty
https://git.ruby-lang.org/ruby.git/commit/?id=90913bfabe From 90913bfabe427993e82d4a72616739ee49e61a5d Mon Sep 17 00:00:00 2001 From: aycabta <aycabta@g...> Date: Sat, 21 Mar 2020 18:13:50 +0900 Subject: [ruby/reline] Suppress error in case INPUTRC env is empty https://github.com/ruby/reline/commit/bce7e7562b diff --git a/lib/reline/config.rb b/lib/reline/config.rb index 61708f9..53b868f 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -83,8 +83,17 @@ class Reline::Config https://github.com/ruby/ruby/blob/trunk/lib/reline/config.rb#L83 @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 14342ff..cecb364 100644 --- a/test/reline/test_config.rb +++ b/test/reline/test_config.rb @@ -206,4 +206,13 @@ class Reline::Config::Test < Reline::TestCase https://github.com/ruby/ruby/blob/trunk/test/reline/test_config.rb#L206 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 -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/