Skip to content

Commit

Permalink
profile: Don't rely on bash syntax
Browse files Browse the repository at this point in the history
In Debian, we reuse flatpak.sh in /etc/X11/Xsession.d (which is sourced
by /bin/sh, normally dash) so that these environment variables become
part of the X11 session environment. We might also have
non-bash-compatible shells that read profile.d (I'm not sure).

Signed-off-by: Simon McVittie <smcv@debian.org>
  • Loading branch information
smcv committed Jan 15, 2019
1 parent 81b2505 commit ceb7aed
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions profile/flatpak.sh
@@ -1,15 +1,23 @@
# set XDG_DATA_DIRS to include Flatpak installations

new_dirs=
while read -r install_path
do
share_path=$install_path/exports/share
case ":$XDG_DATA_DIRS:" in
*":$share_path:"*) :;;
*":$share_path/:"*) :;;
*) new_dirs=${new_dirs:+${new_dirs}:}$share_path;;
esac
done < <(echo "${XDG_DATA_HOME:-"$HOME/.local/share"}/flatpak"; flatpak --installations)
new_dirs=$(
(
echo "${XDG_DATA_HOME:-"$HOME/.local/share"}/flatpak"
flatpak --installations
) | (
new_dirs=
while read -r install_path
do
share_path=$install_path/exports/share
case ":$XDG_DATA_DIRS:" in
*":$share_path:"*) :;;
*":$share_path/:"*) :;;
*) new_dirs=${new_dirs:+${new_dirs}:}$share_path;;
esac
done
echo "$new_dirs"
)
)

export XDG_DATA_DIRS
XDG_DATA_DIRS="${new_dirs:+${new_dirs}:}${XDG_DATA_DIRS:-/usr/local/share:/usr/share}"

0 comments on commit ceb7aed

Please sign in to comment.