summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelfham <38372058+elfham@users.noreply.github.com>2023-09-26 22:08:16 +0900
committergit <svn-admin@ruby-lang.org>2023-09-26 13:08:20 +0000
commit3f1cfc43bdefb45de643076be4602e7b3f432779 (patch)
tree3b1ee73c48055e9f81c4b3140fa651f7375b5529
parentc2c0a083f024f9d0ee7a05c2cdbc4146ff3b2138 (diff)
[ruby/reline] Fix config.rb to File.expand_path $include path in
inputrc (https://github.com/ruby/reline/pull/592) * Fix config.rb to File.expand_path $include path in inputrc * fix bug of test_include_expand_path on Windows https://github.com/ruby/reline/commit/4d34e52d0b
-rw-r--r--lib/reline/config.rb2
-rw-r--r--test/reline/test_config.rb17
2 files changed, 18 insertions, 1 deletions
diff --git a/lib/reline/config.rb b/lib/reline/config.rb
index 87726393a6..4c07a73701 100644
--- a/lib/reline/config.rb
+++ b/lib/reline/config.rb
@@ -252,7 +252,7 @@ class Reline::Config
end
@skip_section = @if_stack.pop
when 'include'
- read(args)
+ read(File.expand_path(args))
end
end
diff --git a/test/reline/test_config.rb b/test/reline/test_config.rb
index b16aed720a..9ead047ce4 100644
--- a/test/reline/test_config.rb
+++ b/test/reline/test_config.rb
@@ -160,6 +160,23 @@ class Reline::Config::Test < Reline::TestCase
assert_equal :audible, @config.instance_variable_get(:@bell_style)
end
+ def test_include_expand_path
+ home_backup = ENV['HOME']
+ File.open('included_partial', 'wt') do |f|
+ f.write(<<~PARTIAL_LINES)
+ set bell-style on
+ PARTIAL_LINES
+ end
+ ENV['HOME'] = Dir.pwd
+ @config.read_lines(<<~LINES.lines)
+ $include ~/included_partial
+ LINES
+
+ assert_equal :audible, @config.instance_variable_get(:@bell_style)
+ ensure
+ ENV['HOME'] = home_backup
+ end
+
def test_if
@config.read_lines(<<~LINES.lines)
$if Ruby