Skip to content

Commit b63bd2e

Browse files
jgarber623ko1
authored andcommitted
Add XDG support for rdbgrc file (#1031)
This commit implements XDG directory support for this gem's `.rdbgrc` configuration file in accordance with the rules outlined in #1031: > 1. prefer `~/.rdbgrc` if present, > 2. else, `$XDG_CONFIG_HOME/rdbg/config` if `$XDG_CONFIG_HOME` is set > and `$XDG_CONFIG_HOME/rdbg/config` is present, > 3. else, no customized user configuration See: #1031 (comment)
1 parent 630dbfa commit b63bd2e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

lib/debug/session.rb

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2300,11 +2300,19 @@ def skip?
23002300
end
23012301

23022302
def self.load_rc
2303-
[[File.expand_path('~/.rdbgrc'), true],
2304-
[File.expand_path('~/.rdbgrc.rb'), true],
2305-
# ['./.rdbgrc', true], # disable because of security concern
2306-
[CONFIG[:init_script], false],
2307-
].each{|(path, rc)|
2303+
rc_file_paths = [
2304+
[File.expand_path('~/.rdbgrc'), true],
2305+
[File.expand_path('~/.rdbgrc.rb'), true],
2306+
# ['./.rdbgrc', true], # disable because of security concern
2307+
]
2308+
2309+
if (xdg_home = ENV["XDG_CONFIG_HOME"])
2310+
rc_file_paths << [File.expand_path(File.join(xdg_home, "rdbg", "config")), true]
2311+
end
2312+
2313+
rc_file_paths << [CONFIG[:init_script], false]
2314+
2315+
rc_file_paths.each{|(path, rc)|
23082316
next unless path
23092317
next if rc && CONFIG[:no_rc] # ignore rc
23102318

0 commit comments

Comments
 (0)