mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[ruby/optparse] Expand literal home paths only
Paths in environment variables should already be expanded.
The base name of the program is also not subject to expansion.
181752391c
This commit is contained in:
parent
1619afb350
commit
deb0240ea0
2 changed files with 37 additions and 5 deletions
|
@ -2047,19 +2047,21 @@ XXX
|
|||
def load(filename = nil, **keywords)
|
||||
unless filename
|
||||
basename = File.basename($0, '.*')
|
||||
return true if load(File.expand_path(basename, '~/.options'), **keywords) rescue nil
|
||||
return true if load(File.expand_path("~/.options/#{basename}"), **keywords) rescue nil
|
||||
basename << ".options"
|
||||
return [
|
||||
# XDG
|
||||
ENV['XDG_CONFIG_HOME'],
|
||||
'~/.config',
|
||||
['~/.config', true],
|
||||
*ENV['XDG_CONFIG_DIRS']&.split(File::PATH_SEPARATOR),
|
||||
|
||||
# Haiku
|
||||
'~/config/settings',
|
||||
].any? {|dir|
|
||||
['~/config/settings', true],
|
||||
].any? {|dir, expand|
|
||||
next if !dir or dir.empty?
|
||||
load(File.expand_path(basename, dir), **keywords) rescue nil
|
||||
filename = File.join(dir, basename)
|
||||
filename = File.expand_path(filename) if expand
|
||||
load(filename, **keywords) rescue nil
|
||||
}
|
||||
end
|
||||
begin
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue