Skip to content

Commit

Permalink
Merge pull request canonical#443 from tomponline/5.21-edge
Browse files Browse the repository at this point in the history
editor: better handle nano rc files (5.21-edge)
  • Loading branch information
tomponline authored Apr 24, 2024
2 parents 34f6a1b + 4d8f6ec commit ba09d8b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion snapcraft/wrappers/editor
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,17 @@ run_cmd() {
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
export HOME="${SNAP_REAL_HOME}"
export USER="${USERNAME}"
IGNORERCFILES=""
if [ "${HOME}" != "/root" ] && [ "${CMD}" = "nano" ]; then
export XDG_DATA_HOME="${HOME}/.local/share"
if [ ! -d "/var/lib/snapd/hostfs/${XDG_DATA_HOME}" ]; then
echo "Instructing nano to ignore RC files due to missing directory: \"${XDG_DATA_HOME}\""
IGNORERCFILES="--ignorercfiles"
fi
fi

# 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}\" \"$@\""
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}\" ${IGNORERCFILES} \"$@\""
}

# Detect base name
Expand Down

0 comments on commit ba09d8b

Please sign in to comment.