Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • xfce4-session xfce4-session
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Graph
    • Compare revisions
  • Issues 71
    • Issues 71
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Artifacts
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Model experiments
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • XfceXfce
  • xfce4-sessionxfce4-session
  • Issues
  • #111

[PATCH] Avoid duplicating directories in the tail of $XDG_* envs

Example input: XDG_CONFIG_DIRS="/etc/xdg/rosa-xfce-config:/etc/xdg"

Output before this patch: XDG_CONFIG_DIRS="/etc/xdg/rosa-xfce-config:/etc/xdg:/etc/xdg"

But there is no need to duplicate /etc/xdg in the tail.

Output after this patch: XDG_CONFIG_DIRS="/etc/xdg/rosa-xfce-config:/etc/xdg"

The scripts that sets XDG_CONFIG_DIRS: https://abf.io/soft/rosa-xfce-config/blob/04b69c389d/profile.d/10-rosa-xfce-config-xdg.sh

Tests for that script: https://abf.io/soft/rosa-xfce-config/blob/04b69c389d/profile.d/test_10-rosa-xfce-config-xdg.sh

I do not see why that my script must not append "/etc/xdg", so fixing startxfce4.

This case-esac code is compatible with POSIX shell (https://stackoverflow.com/a/2830416), but tested it only with bash.

Diff is bellow, git am-able patch is attached.

0001-Avoid-duplicating-directories-in-the-tail-of-XDG_-en.patch

diff --git a/scripts/startxfce4.in b/scripts/startxfce4.in
index bf3201b6..b20a9cf4 100644
--- a/scripts/startxfce4.in
+++ b/scripts/startxfce4.in
@@ -72,7 +72,11 @@ then
     XDG_DATA_DIRS="@_datadir_@:/usr/local/share:/usr/share"
   fi
 else
-  XDG_DATA_DIRS="$XDG_DATA_DIRS:@_datadir_@"
+  # avoid duplicating @_datadir_@ if $XDG_DATA_DIRS already contains it
+  case "$XDG_DATA_DIRS" in
+    *:@_datadir_@ | @_datadir_@ ) : ;;
+    * ) XDG_DATA_DIRS="$XDG_DATA_DIRS:@_datadir_@" ;;
+  esac
 fi
 export XDG_DATA_DIRS
 
@@ -84,7 +88,11 @@ then
     XDG_CONFIG_DIRS="/etc/xdg:@_sysconfdir_@/xdg"
   fi
 else
-  XDG_CONFIG_DIRS="$XDG_CONFIG_DIRS:@_sysconfdir_@/xdg"
+  # avoid duplicating @_sysconfdir_@/xdg if $XDG_CONFIG_DIRS already contains it
+  case "$XDG_CONFIG_DIRS" in
+    *:@_sysconfdir_@/xdg | @_sysconfdir_@/xdg ) : ;;
+    * ) XDG_CONFIG_DIRS="$XDG_CONFIG_DIRS:@_sysconfdir_@/xdg" ;;
+  esac
 fi
 export XDG_CONFIG_DIRS
Edited Apr 12, 2021 by mikhailnov
Assignee
Assign to
Time tracking