Skip to content

Commit 7790978

Browse files
committed
Reverse order for parsing files in XDG_CONFIG_DIRS
https://specifications.freedesktop.org/basedir-spec/latest/ says precedence should be XDG_CONFIG_HOME > 1st entry of XDG_CONFIG_DIRS > 2nd entry ... EasyBuild had this reversed for XDG_CONFIG_DIRS Fixes #4582
1 parent 56db19c commit 7790978

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

easybuild/tools/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def terminal_supports_colors(stream):
123123
CONFIG_ENV_VAR_PREFIX = 'EASYBUILD'
124124

125125
XDG_CONFIG_HOME = os.environ.get('XDG_CONFIG_HOME', os.path.join(os.path.expanduser('~'), ".config"))
126-
XDG_CONFIG_DIRS = os.environ.get('XDG_CONFIG_DIRS', '/etc/xdg').split(os.pathsep)
126+
XDG_CONFIG_DIRS = os.environ.get('XDG_CONFIG_DIRS', '/etc/xdg').split(os.pathsep)[::-1]
127127
DEFAULT_SYS_CFGFILES = [f for d in XDG_CONFIG_DIRS for f in sorted(glob.glob(os.path.join(d, 'easybuild.d', '*.cfg')))]
128128
DEFAULT_USER_CFGFILE = os.path.join(XDG_CONFIG_HOME, 'easybuild', 'config.cfg')
129129

test/framework/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def test_XDG_CONFIG_env_vars(self):
448448

449449
# $XDG_CONFIG_HOME not set, multiple directories listed in $XDG_CONFIG_DIRS
450450
del os.environ['XDG_CONFIG_HOME'] # unset, so should become default
451-
os.environ['XDG_CONFIG_DIRS'] = os.pathsep.join([dir1, dir2, dir3])
451+
os.environ['XDG_CONFIG_DIRS'] = os.pathsep.join([dir3, dir2, dir1])
452452
cfg_files = [
453453
os.path.join(dir1, 'easybuild.d', 'bar.cfg'),
454454
os.path.join(dir1, 'easybuild.d', 'foo.cfg'),

test/framework/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3542,7 +3542,7 @@ def test_show_default_configfiles(self):
35423542

35433543
xdg_config_home = os.path.join(self.test_prefix, 'home')
35443544
os.environ['XDG_CONFIG_HOME'] = xdg_config_home
3545-
xdg_config_dirs = [os.path.join(self.test_prefix, 'etc', 'xdg'), os.path.join(self.test_prefix, 'moaretc')]
3545+
xdg_config_dirs = [os.path.join(self.test_prefix, 'moaretc'), os.path.join(self.test_prefix, 'etc', 'xdg')]
35463546
os.environ['XDG_CONFIG_DIRS'] = os.pathsep.join(xdg_config_dirs)
35473547

35483548
# put various dummy cfgfiles in place
@@ -3563,7 +3563,7 @@ def test_show_default_configfiles(self):
35633563
logtxt = read_file(self.logfile)
35643564
expected = expected_tmpl % (xdg_config_home, os.pathsep.join(xdg_config_dirs),
35653565
"%s => found" % os.path.join(xdg_config_home, 'easybuild', 'config.cfg'),
3566-
'{' + ', '.join(xdg_config_dirs) + '}',
3566+
'{' + ', '.join(xdg_config_dirs[::-1]) + '}',
35673567
', '.join(cfgfiles[:-1]), 4, ', '.join(cfgfiles))
35683568
self.assertIn(expected, logtxt)
35693569

0 commit comments

Comments
 (0)