Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4d34e52

Browse files
authoredSep 26, 2023
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
1 parent c2fc1f7 commit 4d34e52

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed
 

‎lib/reline/config.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ def handle_directive(directive, file, no)
252252
end
253253
@skip_section = @if_stack.pop
254254
when 'include'
255-
read(args)
255+
read(File.expand_path(args))
256256
end
257257
end
258258

‎test/reline/test_config.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,23 @@ def test_include
160160
assert_equal :audible, @config.instance_variable_get(:@bell_style)
161161
end
162162

163+
def test_include_expand_path
164+
home_backup = ENV['HOME']
165+
File.open('included_partial', 'wt') do |f|
166+
f.write(<<~PARTIAL_LINES)
167+
set bell-style on
168+
PARTIAL_LINES
169+
end
170+
ENV['HOME'] = Dir.pwd
171+
@config.read_lines(<<~LINES.lines)
172+
$include ~/included_partial
173+
LINES
174+
175+
assert_equal :audible, @config.instance_variable_get(:@bell_style)
176+
ensure
177+
ENV['HOME'] = home_backup
178+
end
179+
163180
def test_if
164181
@config.read_lines(<<~LINES.lines)
165182
$if Ruby

0 commit comments

Comments
 (0)
Please sign in to comment.