profile: Don't rely on bash syntax

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).

Fixes #2594

Signed-off-by: Simon McVittie <smcv@debian.org>

Closes: #2597
Approved by: matthiasclasen
This commit is contained in:
Simon McVittie
2019-01-15 22:08:37 +00:00
committed by Atomic Bot
parent 96fde5b29c
commit 2a25ecf6ee

View File

@@ -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}"