diff options
author | aycabta <[email protected]> | 2020-04-24 03:10:41 +0900 |
---|---|---|
committer | aycabta <[email protected]> | 2020-04-24 16:46:36 +0900 |
commit | 9fb20711fd4c4c452b1b7391a8ca86a4d82f6b90 (patch) | |
tree | 2f96c3fc017daaea9cd0bdcba29bc25d5dbcfe9c | |
parent | 81b0b7919718bf7f8a6bd9590651b62279977327 (diff) |
[ruby/reline] Treat home dir correctly
https://github.com/ruby/reline/commit/9b1327d2f4
-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) |