distrobox/0001-distrobox-if-no-command-is-specified-default-to-ente.patch

69 lines
1.7 KiB
Diff
Raw Normal View History

From a4f0fd0560c39d58472ef09e4228948e88012d33 Mon Sep 17 00:00:00 2001
From: Dario Faggioli <dfaggioli@suse.com>
Date: Thu, 28 Jul 2022 10:10:28 +0200
Subject: [PATCH] distrobox: if no command is specified, default to enter
If just `distrobox` is invoked, without any command, assume
`distrobox enter`.
Signed-off-by: Dario Faggioli <dfaggioli@suse.com>
---
distrobox | 18 ++++++++++++------
docs/README.md | 1 +
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/distrobox b/distrobox
index 0f83b54..9b53547 100755
--- a/distrobox
+++ b/distrobox
@@ -19,6 +19,12 @@
# along with distrobox; if not, see <http://www.gnu.org/licenses/>.
# POSIX
+# Optional env variables:
+# DBX_DEFAULT_COMMAND
+
+default_command="enter"
+[ -n "${DBX_DEFAULT_COMMAND}" ] && default_command="${DBX_DEFAULT_COMMAND}"
+
set -o errexit
set -o nounset
@@ -48,15 +54,15 @@ Choose one of the available commands:
EOF
}
+distrobox_path="$(dirname "${0}")"
if [ $# -eq 0 ]; then
- show_help
- exit
+ printf "No command specified. Assuming: distrobox-%s\n" "${default_command}"
+ distrobox_command="${default_command}"
+else
+ distrobox_command="${1}"
+ shift
fi
-distrobox_path="$(dirname "${0}")"
-distrobox_command="${1}"
-shift
-
# Simple wrapper to the distrobox utilities.
# We just detect the 1st argument and launch the matching distrobox utility.
case "${distrobox_command}" in
diff --git a/docs/README.md b/docs/README.md
index 8ec20bf..165985f 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -283,6 +283,7 @@ Alternatively it is possible to specify preferences using ENV variables:
- DBX_CONTAINER_NAME
- DBX_NON_INTERACTIVE
- DBX_SKIP_WORKDIR
+- DBX_DEFAULT_COMMAND
---
--
2.37.3