Skip to content

Commit 298b134

Browse files
committed
Do not make non-existent XDG directory on start (#357)
1 parent 46e0f7e commit 298b134

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/irb/init.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,11 +379,9 @@ def IRB.rc_file_generators
379379
end
380380
if xdg_config_home = ENV["XDG_CONFIG_HOME"]
381381
irb_home = File.join(xdg_config_home, "irb")
382-
unless File.exist? irb_home
383-
require 'fileutils'
384-
FileUtils.mkdir_p irb_home
382+
if File.directory?(irb_home)
383+
yield proc{|rc| irb_home + "/irb#{rc}"}
385384
end
386-
yield proc{|rc| irb_home + "/irb#{rc}"}
387385
end
388386
if home = ENV["HOME"]
389387
yield proc{|rc| home+"/.irb#{rc}"}

test/irb/test_init.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,16 @@ def test_setup_with_minimum_argv_does_not_change_dollar0
3636
def test_rc_file
3737
tmpdir = @tmpdir
3838
Dir.chdir(tmpdir) do
39+
ENV["XDG_CONFIG_HOME"] = "#{tmpdir}/xdg"
3940
IRB.conf[:RC_NAME_GENERATOR] = nil
4041
assert_equal(tmpdir+"/.irb#{IRB::IRBRC_EXT}", IRB.rc_file)
4142
assert_equal(tmpdir+"/.irb_history", IRB.rc_file("_history"))
43+
assert_file.not_exist?(tmpdir+"/xdg")
4244
IRB.conf[:RC_NAME_GENERATOR] = nil
4345
FileUtils.touch(tmpdir+"/.irb#{IRB::IRBRC_EXT}")
4446
assert_equal(tmpdir+"/.irb#{IRB::IRBRC_EXT}", IRB.rc_file)
4547
assert_equal(tmpdir+"/.irb_history", IRB.rc_file("_history"))
48+
assert_file.not_exist?(tmpdir+"/xdg")
4649
end
4750
end
4851

0 commit comments

Comments
 (0)