mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/irb] Do not make non-existent XDG directory on start
(https://github.com/ruby/irb/pull/357) https://github.com/ruby/irb/commit/298b134792
This commit is contained in:
parent
56c97a6621
commit
4021c6565f
2 changed files with 5 additions and 4 deletions
|
@ -379,11 +379,9 @@ module IRB # :nodoc:
|
|||
end
|
||||
if xdg_config_home = ENV["XDG_CONFIG_HOME"]
|
||||
irb_home = File.join(xdg_config_home, "irb")
|
||||
unless File.exist? irb_home
|
||||
require 'fileutils'
|
||||
FileUtils.mkdir_p irb_home
|
||||
if File.directory?(irb_home)
|
||||
yield proc{|rc| irb_home + "/irb#{rc}"}
|
||||
end
|
||||
yield proc{|rc| irb_home + "/irb#{rc}"}
|
||||
end
|
||||
if home = ENV["HOME"]
|
||||
yield proc{|rc| home+"/.irb#{rc}"}
|
||||
|
|
|
@ -36,13 +36,16 @@ module TestIRB
|
|||
def test_rc_file
|
||||
tmpdir = @tmpdir
|
||||
Dir.chdir(tmpdir) do
|
||||
ENV["XDG_CONFIG_HOME"] = "#{tmpdir}/xdg"
|
||||
IRB.conf[:RC_NAME_GENERATOR] = nil
|
||||
assert_equal(tmpdir+"/.irb#{IRB::IRBRC_EXT}", IRB.rc_file)
|
||||
assert_equal(tmpdir+"/.irb_history", IRB.rc_file("_history"))
|
||||
assert_file.not_exist?(tmpdir+"/xdg")
|
||||
IRB.conf[:RC_NAME_GENERATOR] = nil
|
||||
FileUtils.touch(tmpdir+"/.irb#{IRB::IRBRC_EXT}")
|
||||
assert_equal(tmpdir+"/.irb#{IRB::IRBRC_EXT}", IRB.rc_file)
|
||||
assert_equal(tmpdir+"/.irb_history", IRB.rc_file("_history"))
|
||||
assert_file.not_exist?(tmpdir+"/xdg")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue