Tweak snapd.fish to be compatible with even older releases of fish, going back to 2.7, which was shipped with Ubuntu 18.04.
* data/env: make fish setup compatible with fish 2.7
Make the environment setup script compatible with fish 2.7 which was shipped
with Ubuntu 18.04.
Thanks to @faho for the review.
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
* tests/main/user-session-env: verify env in fish shell
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
* tests/main/user-session-env: tweak comments
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
* data/env: provide reasonable default if XDG_DATA_DIRS is unset in fish shell
Fixes: https://bugs.launchpad.net/ubuntu/+source/snapd/+bug/1960702
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
* tests/main/user-session-env: verify that XDG_DATA_DIRS contains reasonable defaults
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
Tell fish to treat XDG_DATA_DIRS as a column separated list and not space separated (default).
Otherwise, get corrupted list with mixed separators:
XDG_DATA_DIRS=/var/lib/flatpak/exports/share:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop /var/lib/snapd/desktop /var/lib/snapd/desktop
When PATH contain spaces, which is a really bad idea anyway, the export will
most likely set it to a value up to the first space. Use quoting to prevent
that.
Note, shellcheck does not complain about that, but try this:
sh-5.1$ export foo=foo bar baz
sh-5.1$ echo $foo
foo
sh-5.1$ export foo="foo bar baz"
sh-5.1$ echo $foo
foo bar baz
sh-5.1$
Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>
This has the same properties we were after but is much easier than the
original approach. Shellcheck and rpmlint are both happy now.
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
The snapd.sh file is meant to be sourced so the shebang line is just
some meta-data that shellcheck is using. This meta-data is, however,
also picked up by rpmlint, resulting in the following warning:
[ 73s] snapd.x86_64: W: sourced-script-with-shebang /etc/profile.d/snapd.sh /bin/sh --this-shebang-is-just-here-to-inform-shellcheck--
[ 73s] This text file contains a shebang, but is meant to be sourced, not executed.
This patch keeps the shebang for validation but drops it for
installation.
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
* snap/env: fix env duplication logic
The snap insertion inside environment variables like PATH and XDG_DATA_DIRS
expects that the snap element is always the latest of the path, which isn't
necessarily the case.
Ensure we do substring detection following POSIX.
* Handle subdirectories not matching exact path
Ensure that subdirectory of wanted path doesn't match accidently the wanted
exact path.
As now the syntax is a little bit more complex, factor out wanted path.
All distributions need to add the snappy bin directory (/snap/bin or
/var/lib/snapd/snap/bin, depending) to the user's PATH, and to add
/var/lib/snapd/desktop to XDG_DATA_DIRS (which might be unset, meaning
it needs adding to the defaults).
Up to now all distros were doing this separately, so we had a bunch of
duplication. Also, as things move to Wayland, on debian-based distros
XDG_DATA_DIRS was only being set in X sessions which mean that
switching to wayland lost you your snappy desktop files.
This tries to fix all that, hopefully in a sane way.