From dbda6c03d9e12e155c118368386435f2f383e602 Mon Sep 17 00:00:00 2001 From: Hans Goor Date: Sun, 1 Sep 2024 20:48:31 +0200 Subject: [PATCH] Clean up the autoshell and make it faster on subsequent runs. --- stowers/shell-utils/dot-local/bin/toolbx | 6 ++---- .../eyedevelop/shell-utils/toolbx/container_autoshell.sh | 7 +++++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/stowers/shell-utils/dot-local/bin/toolbx b/stowers/shell-utils/dot-local/bin/toolbx index 409828f..d2b155b 100755 --- a/stowers/shell-utils/dot-local/bin/toolbx +++ b/stowers/shell-utils/dot-local/bin/toolbx @@ -68,7 +68,7 @@ enter_toolbox() { create_toolbox fi - podman exec -it "${TOOLBX_NAME}" "/autoshell.sh" "${SHELL}" + podman exec -it --env=_REAL_USER="${USER}" "${TOOLBX_NAME}" "/autoshell.sh" "${SHELL}" } print_usage() { @@ -80,13 +80,11 @@ print_usage() { echo " -i|--image -- The image to use to create the toolbox with." echo " -p|--privileged -- Whether the toolbox is privileged or not." echo " delete -- Delete the current toolbox." - echo - echo "If no command is specified, enter is assumed." } if [[ "$#" -lt 1 ]]; then print_usage - return 1 + exit 1 fi while [[ "$#" -ge 1 ]]; do diff --git a/stowers/shell-utils/dot-local/share/eyedevelop/shell-utils/toolbx/container_autoshell.sh b/stowers/shell-utils/dot-local/share/eyedevelop/shell-utils/toolbx/container_autoshell.sh index c7e622f..e7ae478 100755 --- a/stowers/shell-utils/dot-local/share/eyedevelop/shell-utils/toolbx/container_autoshell.sh +++ b/stowers/shell-utils/dot-local/share/eyedevelop/shell-utils/toolbx/container_autoshell.sh @@ -9,7 +9,7 @@ install_shell() { case "${ID}" in debian) - apt-get -y update && apt-get -y install "$(apt-file update &>/dev/null && apt-file search -l "${REAL_SHELL}" | head -n1 )" + apt-get -y update && apt-get -y install "$(apt-file update &>/dev/null && apt-file search -lF "${REAL_SHELL}" | head -n1 )" ;; *) @@ -26,5 +26,8 @@ start_shell() { fi } -install_shell >/dev/null || true +if ! command -v "${REAL_SHELL}" &>/dev/null; then + install_shell >/dev/null || true +fi + start_shell "$@"