Skip to content

Commit

Permalink
all: ensure env variables are set and have values
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Di Maio <[email protected]>
  • Loading branch information
89luca89 committed May 9, 2024
1 parent b27c6d3 commit 9b608a0
Show file tree
Hide file tree
Showing 11 changed files with 55 additions and 0 deletions.
5 changes: 5 additions & 0 deletions distrobox-assemble
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
# You should have received a copy of the GNU General Public License
# along with distrobox; if not, see <http://www.gnu.org/licenses/>.

# Ensure we have our env variables correctly set
[ -z "${USER}" ] && USER="$(id -run)"
[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"

# POSIX
#
default_input_file="./distrobox.ini"
Expand Down
5 changes: 5 additions & 0 deletions distrobox-create
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ if {
exit 1
fi

# Ensure we have our env variables correctly set
[ -z "${USER}" ] && USER="$(id -run)"
[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"

# Defaults
container_additional_packages=""
container_additional_volumes=""
Expand Down
5 changes: 5 additions & 0 deletions distrobox-enter
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@
# DBX_SKIP_WORKDIR
# DBX_SUDO_PROGRAM

# Ensure we have our env variables correctly set
[ -z "${USER}" ] && USER="$(id -run)"
[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"

app_cache_dir=${XDG_CACHE_HOME:-"${HOME}/.cache"}/distrobox

trap cleanup TERM INT HUP EXIT
Expand Down
5 changes: 5 additions & 0 deletions distrobox-ephemeral
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ if {
exit 1
fi

# Ensure we have our env variables correctly set
[ -z "${USER}" ] && USER="$(id -run)"
[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"

trap cleanup TERM INT HUP

name=$(mktemp -u distrobox-XXXXXXXXXX)
Expand Down
5 changes: 5 additions & 0 deletions distrobox-export
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
# DISTROBOX_ENTER_PATH
# DISTROBOX_HOST_HOME

# Ensure we have our env variables correctly set
[ -z "${USER}" ] && USER="$(id -run)"
[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"

# Defaults
export_action=""
exported_app=""
Expand Down
5 changes: 5 additions & 0 deletions distrobox-generate-entry
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ if {
exit 1
fi

# Ensure we have our env variables correctly set
[ -z "${USER}" ] && USER="$(id -run)"
[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"

# If the user runs this script as root in a login shell, set rootful=1.
# There's no need for them to pass the --root flag option in such cases.
[ "$(id -ru)" -eq 0 ] && rootful=1 || rootful=0
Expand Down
5 changes: 5 additions & 0 deletions distrobox-host-exec
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
# You should have received a copy of the GNU General Public License
# along with distrobox; if not, see <http://www.gnu.org/licenses/>.

# Ensure we have our env variables correctly set
[ -z "${USER}" ] && USER="$(id -run)"
[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"

# Defaults
host_command=""
non_interactive=0
Expand Down
5 changes: 5 additions & 0 deletions distrobox-list
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ if {
exit 1
fi

# Ensure we have our env variables correctly set
[ -z "${USER}" ] && USER="$(id -run)"
[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"

# Defaults
no_color=0
# If the user runs this script as root in a login shell, set rootful=1.
Expand Down
5 changes: 5 additions & 0 deletions distrobox-rm
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ if {
exit 1
fi

# Ensure we have our env variables correctly set
[ -z "${USER}" ] && USER="$(id -run)"
[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"

# Defaults
all=0
container_manager="autodetect"
Expand Down
5 changes: 5 additions & 0 deletions distrobox-stop
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ if {
exit 1
fi

# Ensure we have our env variables correctly set
[ -z "${USER}" ] && USER="$(id -run)"
[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"

# Defaults
all=0
container_manager="autodetect"
Expand Down
5 changes: 5 additions & 0 deletions distrobox-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ if {
exit 1
fi

# Ensure we have our env variables correctly set
[ -z "${USER}" ] && USER="$(id -run)"
[ -z "${HOME}" ] && HOME="$(getent passwd "${USER}" | cut -d':' -f6)"
[ -z "${SHELL}" ] && SHELL="$(getent passwd "${USER}" | cut -d':' -f7)"

all=0
running=0
container_manager="autodetect"
Expand Down

0 comments on commit 9b608a0

Please sign in to comment.