[前][次][番号順一覧][スレッド一覧]

ruby-changes:60889

From: aycabta <ko1@a...>
Date: Fri, 24 Apr 2020 16:47:35 +0900 (JST)
Subject: [ruby-changes:60889] 9fb20711fd (master): [ruby/reline] Treat home dir correctly

https://git.ruby-lang.org/ruby.git/commit/?id=9fb20711fd

From 9fb20711fd4c4c452b1b7391a8ca86a4d82f6b90 Mon Sep 17 00:00:00 2001
From: aycabta <aycabta@g...>
Date: Fri, 24 Apr 2020 03:10:41 +0900
Subject: [ruby/reline] Treat home dir correctly

https://github.com/ruby/reline/commit/9b1327d2f4

diff --git a/lib/reline/config.rb b/lib/reline/config.rb
index 0e5488e..b299bcc 100644
--- a/lib/reline/config.rb
+++ b/lib/reline/config.rb
@@ -91,8 +91,8 @@ class Reline::Config https://github.com/ruby/ruby/blob/trunk/lib/reline/config.rb#L91
     # 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 https://github.com/ruby/ruby/blob/trunk/lib/reline/config.rb#L102
       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 c1a4a46..bf980a2 100644
--- a/test/reline/test_config.rb
+++ b/test/reline/test_config.rb
@@ -227,12 +227,11 @@ class Reline::Config::Test < Reline::TestCase https://github.com/ruby/ruby/blob/trunk/test/reline/test_config.rb#L227
   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)
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]