diff --git a/lib/debug/console.rb b/lib/debug/console.rb index 53545e5e9..bc37276fd 100644 --- a/lib/debug/console.rb +++ b/lib/debug/console.rb @@ -153,13 +153,20 @@ def history end def history_file - history_file = CONFIG[:history_file] + path = + if !CONFIG[:history_file].empty? && File.exist?(File.expand_path(CONFIG[:history_file])) + CONFIG[:history_file] + elsif (xdg_home = ENV['XDG_DATA_HOME']) + File.join(xdg_home, 'rdbg', 'history') + else + '~/.rdbg_history' + end - if !history_file.empty? - File.expand_path(history_file) - else - history_file - end + path = File.expand_path(path) + + FileUtils.mkdir_p(File.dirname(path)) unless File.exist?(path) + + path end FH = "# Today's OMIKUJI: " diff --git a/lib/debug/session.rb b/lib/debug/session.rb index f76f9dc6d..be4a63b66 100644 --- a/lib/debug/session.rb +++ b/lib/debug/session.rb @@ -2293,11 +2293,20 @@ def skip? end def self.load_rc - [[File.expand_path('~/.rdbgrc'), true], - [File.expand_path('~/.rdbgrc.rb'), true], - # ['./.rdbgrc', true], # disable because of security concern - [CONFIG[:init_script], false], - ].each{|(path, rc)| + rc_file_paths = [ + [File.expand_path('~/.rdbgrc'), true], + [File.expand_path('~/.rdbgrc.rb'), true], + # ['./.rdbgrc', true], # disable because of security concern + ] + + if (xdg_home = ENV["XDG_CONFIG_HOME"]) + rc_file_paths << [File.expand_path(File.join(xdg_home, "rdbg", "config")), true] + rc_file_paths << [File.expand_path(File.join(xdg_home, "rdbg", "config.rb")), true] + end + + rc_file_paths << [CONFIG[:init_script], false] + + rc_file_paths.each{|(path, rc)| next unless path next if rc && CONFIG[:no_rc] # ignore rc