Skip to content

Commit

Permalink
Fix logic for default XDG_DATA_DIRS value
Browse files Browse the repository at this point in the history
The [POSIX test manpage](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html)
as well as the [fish test manpage](https://fishshell.com/docs/current/cmds/test.html#operators-for-text-strings)
specify that `-z` will be "True if the length of string string is zero;
otherwise, false."

The `-n` was likely a mixup and not caught during testing of
#8985 due to a lack of missing
conflicting entries in `XDG_DATA_DIRS`.
  • Loading branch information
iFreilicht authored and fricklerhandwerk committed Nov 7, 2023
1 parent fe62cb7 commit 1362a0a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion scripts/nix-profile-daemon.fish.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ set __ETC_PROFILE_NIX_SOURCED 1
set --export NIX_PROFILES "@localstatedir@/nix/profiles/default $HOME/.nix-profile"

# Populate bash completions, .desktop files, etc
if test -n "$XDG_DATA_DIRS"
if test -z "$XDG_DATA_DIRS"
# According to XDG spec the default is /usr/local/share:/usr/share, don't set something that prevents that default
set --export XDG_DATA_DIRS "/usr/local/share:/usr/share:/nix/var/nix/profiles/default/share"
else
Expand Down
2 changes: 1 addition & 1 deletion scripts/nix-profile-daemon.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fi
export NIX_PROFILES="@localstatedir@/nix/profiles/default $NIX_LINK"

# Populate bash completions, .desktop files, etc
if [ -n "${XDG_DATA_DIRS-}" ]; then
if [ -z "$XDG_DATA_DIRS" ]; then
# According to XDG spec the default is /usr/local/share:/usr/share, don't set something that prevents that default
export XDG_DATA_DIRS="/usr/local/share:/usr/share:$NIX_LINK/share:/nix/var/nix/profiles/default/share"
else
Expand Down
2 changes: 1 addition & 1 deletion scripts/nix-profile.fish.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if test -n "$HOME" && test -n "$USER"
set --export NIX_PROFILES "@localstatedir@/nix/profiles/default $HOME/.nix-profile"

# Populate bash completions, .desktop files, etc
if test -n "$XDG_DATA_DIRS"
if test -z "$XDG_DATA_DIRS"
# According to XDG spec the default is /usr/local/share:/usr/share, don't set something that prevents that default
set --export XDG_DATA_DIRS "/usr/local/share:/usr/share:$NIX_LINK/share:/nix/var/nix/profiles/default/share"
else
Expand Down
2 changes: 1 addition & 1 deletion scripts/nix-profile.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ if [ -n "$HOME" ] && [ -n "$USER" ]; then
export NIX_PROFILES="@localstatedir@/nix/profiles/default $NIX_LINK"

# Populate bash completions, .desktop files, etc
if [ -n "${XDG_DATA_DIRS-}" ]; then
if [ -z "$XDG_DATA_DIRS" ]; then
# According to XDG spec the default is /usr/local/share:/usr/share, don't set something that prevents that default
export XDG_DATA_DIRS="/usr/local/share:/usr/share:$NIX_LINK/share:/nix/var/nix/profiles/default/share"
else
Expand Down

0 comments on commit 1362a0a

Please sign in to comment.