From 4cc8c9b37bb071fdbf2bbc5abc6e2edaa346b033 Mon Sep 17 00:00:00 2001 From: Myxa Date: Sat, 23 Dec 2023 23:39:56 +0400 Subject: [PATCH] 'cmd/enter': replace usage of '$SHELL' with '/usr/bin/env ' Signed-off-by: Myxa --- src/cmd/enter.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/cmd/enter.go b/src/cmd/enter.go index 5f43fda..1361197 100644 --- a/src/cmd/enter.go +++ b/src/cmd/enter.go @@ -20,6 +20,7 @@ import ( "errors" "fmt" "os" + "path" "github.com/containers/toolbox/pkg/utils" "github.com/spf13/cobra" @@ -117,12 +118,18 @@ func enter(cmd *cobra.Command, args []string) error { return err } - userShell := os.Getenv("SHELL") - if userShell == "" { - return errors.New("failed to get the current user's default shell") + userShellBinPath := os.Getenv("SHELL") + if userShellBinPath == "" { + return errors.New("failed to get the current path to user's default shell executable") } - command := []string{userShell, "-l"} + _, userShellName := path.Split(userShellBinPath) + + if userShellName == "" { + return errors.New("failed to get the current user's default shell name") + } + + command := []string{"/usr/bin/env", userShellName, "-l"} if err := runCommand(container, defaultContainer, image, release, 0, command, true, true, false); err != nil { return err