-
-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up $XDG_DATA_DIRS
and adhere to the XDG Base Directory Specification
#150
base: main
Are you sure you want to change the base?
Conversation
The XDG Base Directory Specification states: > If $XDG_DATA_DIRS is either not set or empty, a value equal to > /usr/local/share/:/usr/share/ should be used. Fix: sonnyp#115
Flatpak[1] and Snapd[2] set up the base directories themselves. [1]: https://github.com/flatpak/flatpak/blob/main/profile/flatpak.sh [2]: https://github.com/snapcore/snapd/blob/master/data/env/snapd.sh.in
@@ -1,4 +1,4 @@ | |||
#!/usr/bin/env -S XDG_DATA_DIRS=${XDG_DATA_DIRS}:/run/host/usr/share:/var/lib/snapd/desktop:/var/lib/flatpak/exports/share:${HOME}/.local/share/flatpak/exports/share gjs -m | |||
#!/usr/bin/env -S XDG_DATA_DIRS=${XDG_DATA_DIRS:-/usr/local/share:/usr/share}:/run/host/usr/share gjs -m |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not familiar with this syntax - can you explain the -
or point me to documentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick response! If you are referring to the ${var:-default}
shell syntax, it substitutes the default value default
if ${var}
is unset or null:
From the Bash manpage:
${parameter:-word}
Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sonnyp Can I help you with anything else? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick response! If you are referring to the
${var:-default}
shell syntax, it substitutes the default valuedefault
if${var}
is unset or null:From the Bash manpage:
${parameter:-word}
Use Default Values. If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.
Something doesn't work with this syntax, the following error is received:
$ re.sonny.Junction
/usr/bin/env: only ${VARNAME} expansion is supported, error at: ${XDG_DATA_DIRS:-/usr/local/share:/usr/share}:/run/host/usr/share gjs -m
Maybe env (at least on my arch) does not support this ${parameter:-word}
shell syntax.
This syntax works (of course it will overwrite the value)
#!/usr/bin/env -S XDG_DATA_DIRS=/usr/local/share:/usr/share:/run/host/usr/share gjs -m
The first commit fixes a startup error (#115), when
$XDG_DATA_DIRS
is not defined and thus gets incorrectly setto
:/run/host/usr/share:/var/lib/snapd/desktop:/var/lib/flatpak/exports/share:${HOME}/.local/share/flatpak/exports/share
while the XDG Base Directory Specification states:The second commit removes entries from
$XDG_DATA_DIRS
that Snapd and Flatpak set themselves already.I found a downstream incident report, where Junction "doesn't work with programs that do their own weird stuff and end up clearing the env". I didn't investigate this further, since I believe that this was either a user error or the programs in question need to properly handle
$XDG*
variables.I mentioned it in case it's relevant to this PR.