diff options
-rw-r--r-- | lib/reline/config.rb | 6 | ||||
-rw-r--r-- | test/reline/test_config.rb | 3 |
2 files changed, 5 insertions, 4 deletions
diff --git a/lib/reline/config.rb b/lib/reline/config.rb index 0e5488eefb..b299bcc9cd 100644 --- a/lib/reline/config.rb +++ b/lib/reline/config.rb @@ -91,8 +91,8 @@ class Reline::Config # In the XDG Specification, if ~/.config/readline/inputrc exists, then # ~/.inputrc should not be read, but for compatibility with GNU Readline, # if ~/.inputrc exists, then it is given priority. - path = File.expand_path('~/.inputrc') - return path if File.exist?(path) + home_rc_path = File.expand_path('~/.inputrc') + return home_rc_path if File.exist?(home_rc_path) case ENV['XDG_CONFIG_HOME'] when nil, '' @@ -102,6 +102,8 @@ class Reline::Config path = File.expand_path("#{ENV['XDG_CONFIG_HOME']}/readline/inputrc") return path if File.exist?(path) end + + return home_rc_path end def read(file = nil) diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb index c1a4a46ecf..bf980a2c98 100644 --- a/test/reline/test_config.rb +++ b/test/reline/test_config.rb @@ -227,12 +227,11 @@ class Reline::Config::Test < Reline::TestCase def test_xdg_config_home home_backup = ENV['HOME'] xdg_config_home_backup = ENV['XDG_CONFIG_HOME'] - nonexistence_dir = '/the_nonexistence_dir!!!!!!' xdg_config_home = File.expand_path("#{@tmpdir}/.config/example_dir") expected = File.expand_path("#{xdg_config_home}/readline/inputrc") FileUtils.mkdir_p(File.dirname(expected)) FileUtils.touch(expected) - ENV['HOME'] = nonexistence_dir + ENV['HOME'] = @tmpdir ENV['XDG_CONFIG_HOME'] = xdg_config_home assert_equal expected, @config.inputrc_path FileUtils.rm(expected) |