7 Commits

Author SHA1 Message Date
Maciej Borzecki
ae84b651f4 data/env/snapd: use quoting in case PATH contains spaces
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>
2021-02-02 09:56:48 +01:00
Vladimir Jelovac
7db04cf54b Fixing shellcheck warnings. 2020-04-18 11:25:30 +02:00
Zygmunt Krynicki
8f769b04ca data/env: use "# shellcheck shell=sh" instead of shebang
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>
2018-06-20 12:24:12 +02:00
Zygmunt Krynicki
e2044ec5da data: remove /bin/sh from snapd.sh
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>
2018-06-20 09:31:29 +02:00
Didier Roche
526b770852 snap/env: fix env duplication logic (#5075)
* 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.
2018-05-18 08:44:56 +02:00
John R. Lenton
67b6ba2483 Fix 14.04 (thank you spread), address review feedback (thank you mvo)
Also do some work to keep the diffs between 14.04 and 16.04 small.
2017-08-29 18:32:47 +01:00
John R. Lenton
2f55619677 packaging: unify PATH and XDG_DATA_DIRS handling cross-distro
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.
2017-08-29 13:32:03 +01:00