From 6e9dc4ad89eec3db205a4b158338f43250dff8bc Mon Sep 17 00:00:00 2001 From: Debarshi Ray Date: Wed, 17 Apr 2019 11:58:26 +0200 Subject: [PATCH] Split out the code to create the command string to enter a container A subsequent commit will leverage this to suggest how to enter a toolbox container that's already present. https://github.com/debarshiray/toolbox/issues/59 --- toolbox | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/toolbox b/toolbox index f11e336..5d63ec3 100755 --- a/toolbox +++ b/toolbox @@ -303,6 +303,20 @@ container_name_is_valid() ) +create_enter_command() +( + container="$1" + + if [ "$container" = "$toolbox_container_default" ] 2>&3; then + echo "$base_toolbox_command enter" + elif [ "$container" = "$toolbox_container_prefix_default-$release" ] 2>&3; then + echo "$base_toolbox_command enter --release $release" + else + echo "$base_toolbox_command enter --container $container" + fi +) + + create_environment_options() { echo "$environment_variables" \ @@ -740,15 +754,7 @@ create() echo "Created container: $toolbox_container" - enter_command="" - if [ "$toolbox_container" = "$toolbox_container_default" ] 2>&3; then - enter_command="$base_toolbox_command enter" - elif [ "$toolbox_container" = "$toolbox_container_prefix_default-$release" ] 2>&3; then - enter_command="$base_toolbox_command enter --release $release" - else - enter_command="$base_toolbox_command enter --container $toolbox_container" - fi - + enter_command=$(create_enter_command "$toolbox_container") echo "Enter with: $enter_command" )