74 lines
1.9 KiB
Diff
74 lines
1.9 KiB
Diff
|
From 0f1a928d310ea35465f892ff0bda563d110a4ce7 Mon Sep 17 00:00:00 2001
|
||
|
From: Dario Faggioli <dfaggioli@suse.com>
|
||
|
Date: Thu, 28 Jul 2022 10:10:28 +0200
|
||
|
Subject: [PATCH 3/4] 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 | 19 ++++++++++++-------
|
||
|
docs/README.md | 1 +
|
||
|
2 files changed, 13 insertions(+), 7 deletions(-)
|
||
|
|
||
|
diff --git a/distrobox b/distrobox
|
||
|
index 4e37031..ce0469c 100755
|
||
|
--- a/distrobox
|
||
|
+++ b/distrobox
|
||
|
@@ -19,6 +19,11 @@
|
||
|
# 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}"
|
||
|
|
||
|
trap '[ "$?" -ne 0 ] && printf "\nAn error occurred\n"' EXIT
|
||
|
|
||
|
@@ -43,11 +48,6 @@ Choose one of the available commands:
|
||
|
EOF
|
||
|
}
|
||
|
|
||
|
-if [ $# -eq 0 ]; then
|
||
|
- show_help
|
||
|
- exit
|
||
|
-fi
|
||
|
-
|
||
|
# Handle 'help' here, before setting 'errexit', so we have a chance
|
||
|
# to show our help if the man command is there but fails.
|
||
|
if [ "$1" = "help" ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
||
|
@@ -62,8 +62,13 @@ set -o errexit
|
||
|
set -o nounset
|
||
|
|
||
|
distrobox_path="$(dirname "${0}")"
|
||
|
-distrobox_command="${1}"
|
||
|
-shift
|
||
|
+if [ $# -eq 0 ]; then
|
||
|
+ printf "No command specified. Assuming: distrobox-%s\n" "${default_command}"
|
||
|
+ distrobox_command="${default_command}"
|
||
|
+else
|
||
|
+ distrobox_command="${1}"
|
||
|
+ shift
|
||
|
+fi
|
||
|
|
||
|
# Simple wrapper to the distrobox utilities.
|
||
|
# We just detect the 1st argument and launch the matching distrobox utility.
|
||
|
diff --git a/docs/README.md b/docs/README.md
|
||
|
index df00785..64e4c0d 100644
|
||
|
--- a/docs/README.md
|
||
|
+++ b/docs/README.md
|
||
|
@@ -268,6 +268,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.1
|
||
|
|