From 4d34e52d0ba4f02127172f0f6cbd67cb2f487755 Mon Sep 17 00:00:00 2001 From: elfham <38372058+elfham@users.noreply.github.com> Date: Tue, 26 Sep 2023 22:08:16 +0900 Subject: [PATCH] Fix config.rb to File.expand_path $include path in inputrc (#592) * Fix config.rb to File.expand_path $include path in inputrc * fix bug of test_include_expand_path on Windows --- lib/reline/config.rb | 2 +- test/reline/test_config.rb | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) 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 @@ def handle_directive(directive, file, no) 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 @@ def test_include 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