Skip to content

Commit

Permalink
Fix config.rb to File.expand_path $include path in inputrc (#592)
Browse files Browse the repository at this point in the history
* Fix config.rb to File.expand_path $include path in inputrc

* fix bug of test_include_expand_path on Windows
  • Loading branch information
elfham authored Sep 26, 2023
1 parent c2fc1f7 commit 4d34e52
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/reline/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 17 additions & 0 deletions test/reline/test_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4d34e52

Please sign in to comment.