Files
flatpak/profile/flatpak.sh
Ross Timson a48f46f314 profile: Fix for openbsd ksh.
When using OpenBSD ksh `flatpak.sh` gives the following error:

	/etc/profile.d/flatpak.sh[16]: syntax error: `;;' unexpected

By adding in the POSIX compliant optional opening parentheses for the
case statement branches the profile can be made more portable.  This
still works with them more common shells such as bash and zsh and also
still passes `shellcheck` checks.

Aware that using OpenBSD ksh on Linux might be an edge case but there
are probably BSD users who need to use Linux for work such as myself but
still want to use the OBSD shell which has been ported to Linux:
https://github.com/dimkr/loksh

Many thanks to @gumnos for pointing out the fix here via Twitter.

Closes: #2947
Approved by: mwleeds
2019-06-11 19:20:25 +00:00

27 lines
813 B
Bash

if command -v flatpak > /dev/null; then
# set XDG_DATA_DIRS to include Flatpak installations
new_dirs=$(
(
unset G_MESSAGES_DEBUG
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}"
fi