diff --git a/scripts/upstream/distrobox-enter.upstream b/scripts/upstream/distrobox-enter.upstream index 0a3ce30f..9c706728 100644 --- a/scripts/upstream/distrobox-enter.upstream +++ b/scripts/upstream/distrobox-enter.upstream @@ -1,4 +1,4 @@ -#!/usr/bin/sh +#!/bin/sh # SPDX-License-Identifier: GPL-3.0-only # # This file is part of the distrobox project: @@ -109,7 +109,7 @@ headless=0 skip_workdir=0 verbose=0 clean_path=0 -version="1.8.1.2.1" +version="1.8.2.4" # Source configuration files, this is done in an hierarchy so local files have # priority over system defaults @@ -422,6 +422,8 @@ generate_enter_command() result_command="${result_command} --workdir=${workdir}" + result_command="${result_command} + --env=PWD=${workdir}" result_command="${result_command} --env=CONTAINER_ID=${container_name}" result_command="${result_command} @@ -431,15 +433,14 @@ generate_enter_command() # and export them to the container. set +o xtrace # disable logging for this snippet, or it will be too talkative. - for i in $(printenv | grep '=' | grep -Ev ' |"|`|\$' | - grep -Ev '^(CONTAINER_ID|FPATH|HOST|HOSTNAME|HOME|PATH|PROFILEREAD|SHELL|XDG_SEAT|XDG_VTNR|XDG_.*_DIRS|^_)'); do - # We filter the environment so that we do not have strange variables, - # multiline or containing spaces. - # We also NEED to ignore the HOME variable, as this is set at create time - # and needs to stay that way to use custom home dirs. - result_command="${result_command} - --env=${i}" - done + # We filter the environment so that we do not have strange variables or + # multiline. + # We also NEED to ignore the HOME variable, as this is set at create time + # and needs to stay that way to use custom home dirs. or it will be too talkative. + result_command="${result_command} + $(printenv | grep '=' | grep -Ev '"|`|\$' | + grep -Ev '^(CONTAINER_ID|FPATH|HOST|HOSTNAME|HOME|PATH|PROFILEREAD|PWD|SHELL|XDG_SEAT|XDG_VTNR|XDG_.*_DIRS|^_)' | + sed 's/ /\ /g' | sed 's/^\(.*\)$/--env=\1/g')" # Start with the $PATH set in the container's config container_paths="${container_path:-""}" @@ -704,6 +705,7 @@ if [ "${unshare_groups:-0}" -eq 1 ]; then if [ "${headless}" -eq 0 ]; then set -- "--pty" "$@" fi + set -- "-m" "$@" set -- "${container_command_user}" "$@" set -- "su" "$@" fi