mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
81b0b79197
commit
9fb20711fd
2 changed files with 5 additions and 4 deletions
|
@ -91,8 +91,8 @@ class Reline::Config
|
||||||
# In the XDG Specification, if ~/.config/readline/inputrc exists, then
|
# In the XDG Specification, if ~/.config/readline/inputrc exists, then
|
||||||
# ~/.inputrc should not be read, but for compatibility with GNU Readline,
|
# ~/.inputrc should not be read, but for compatibility with GNU Readline,
|
||||||
# if ~/.inputrc exists, then it is given priority.
|
# if ~/.inputrc exists, then it is given priority.
|
||||||
path = File.expand_path('~/.inputrc')
|
home_rc_path = File.expand_path('~/.inputrc')
|
||||||
return path if File.exist?(path)
|
return home_rc_path if File.exist?(home_rc_path)
|
||||||
|
|
||||||
case ENV['XDG_CONFIG_HOME']
|
case ENV['XDG_CONFIG_HOME']
|
||||||
when nil, ''
|
when nil, ''
|
||||||
|
@ -102,6 +102,8 @@ class Reline::Config
|
||||||
path = File.expand_path("#{ENV['XDG_CONFIG_HOME']}/readline/inputrc")
|
path = File.expand_path("#{ENV['XDG_CONFIG_HOME']}/readline/inputrc")
|
||||||
return path if File.exist?(path)
|
return path if File.exist?(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return home_rc_path
|
||||||
end
|
end
|
||||||
|
|
||||||
def read(file = nil)
|
def read(file = nil)
|
||||||
|
|
|
@ -227,12 +227,11 @@ class Reline::Config::Test < Reline::TestCase
|
||||||
def test_xdg_config_home
|
def test_xdg_config_home
|
||||||
home_backup = ENV['HOME']
|
home_backup = ENV['HOME']
|
||||||
xdg_config_home_backup = ENV['XDG_CONFIG_HOME']
|
xdg_config_home_backup = ENV['XDG_CONFIG_HOME']
|
||||||
nonexistence_dir = '/the_nonexistence_dir!!!!!!'
|
|
||||||
xdg_config_home = File.expand_path("#{@tmpdir}/.config/example_dir")
|
xdg_config_home = File.expand_path("#{@tmpdir}/.config/example_dir")
|
||||||
expected = File.expand_path("#{xdg_config_home}/readline/inputrc")
|
expected = File.expand_path("#{xdg_config_home}/readline/inputrc")
|
||||||
FileUtils.mkdir_p(File.dirname(expected))
|
FileUtils.mkdir_p(File.dirname(expected))
|
||||||
FileUtils.touch(expected)
|
FileUtils.touch(expected)
|
||||||
ENV['HOME'] = nonexistence_dir
|
ENV['HOME'] = @tmpdir
|
||||||
ENV['XDG_CONFIG_HOME'] = xdg_config_home
|
ENV['XDG_CONFIG_HOME'] = xdg_config_home
|
||||||
assert_equal expected, @config.inputrc_path
|
assert_equal expected, @config.inputrc_path
|
||||||
FileUtils.rm(expected)
|
FileUtils.rm(expected)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue