Skip to content

Commit

Permalink
snapcraft/wrappers/editor: do not export XDG_ vars
Browse files Browse the repository at this point in the history
`lxc config edit` would generate some noise if `/root/.local` didn't exist:

```
Unable to create directory /root/.local/share//nano/: No such file or directory
It is required for saving/loading search history or cursor positions.
```

Normally, `nano` would create the hiearchy `/root/.local/share/nano/` itself if
XDG_DATA_HOME is not defined. This hiearchy creation logic is skipped if the
variable is defined.

The spec [1] contains this:

> If $XDG_DATA_HOME is either not set or empty, a default equal to $HOME/.local/share should be used.
> If $XDG_CONFIG_HOME is either not set or empty, a default equal to $HOME/.config should be used.
> If $XDG_STATE_HOME is either not set or empty, a default equal to $HOME/.local/state should be used.

So let's not export those as `nano` knows about those defaults and can then
create the proper directories without warnings.

[1]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables

Signed-off-by: Simon Deziel <[email protected]>
(cherry picked from commit 7dcb188)
  • Loading branch information
simondeziel committed Mar 14, 2024
1 parent a2a30bb commit dcdef06
Showing 1 changed file with 0 additions and 3 deletions.
3 changes: 0 additions & 3 deletions snapcraft/wrappers/editor
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ run_cmd() {
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export HOME="${SNAP_REAL_HOME}"
export USER="${USERNAME}"
[ -z "${XDG_DATA_HOME:-}" ] && export XDG_DATA_HOME="${HOME}/.local/share/"
[ -z "${XDG_CONFIG_HOME:-}" ] && export XDG_CONFIG_HOME="${HOME}/.config/"
[ -z "${XDG_STATE_HOME:-}" ] && export XDG_STATE_HOME="${HOME}/.local/state/"

# shellcheck disable=SC2145
exec unshare --kill-child -U -m -p -r -f --root="/var/lib/snapd/hostfs/" "/bin/sh" -c "mount -t proc proc /proc 2>/dev/null || true; exec \"${CMD}\" \"$@\""
Expand Down

0 comments on commit dcdef06

Please sign in to comment.