Skip to content

Commit 4cc8c9b

Browse files
committed
'cmd/enter': replace usage of '$SHELL' with '/usr/bin/env <shell-name>'
Signed-off-by: Myxa <[email protected]>
1 parent d2316b2 commit 4cc8c9b

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/cmd/enter.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"errors"
2121
"fmt"
2222
"os"
23+
"path"
2324

2425
"github.com/containers/toolbox/pkg/utils"
2526
"github.com/spf13/cobra"
@@ -117,12 +118,18 @@ func enter(cmd *cobra.Command, args []string) error {
117118
return err
118119
}
119120

120-
userShell := os.Getenv("SHELL")
121-
if userShell == "" {
122-
return errors.New("failed to get the current user's default shell")
121+
userShellBinPath := os.Getenv("SHELL")
122+
if userShellBinPath == "" {
123+
return errors.New("failed to get the current path to user's default shell executable")
123124
}
124125

125-
command := []string{userShell, "-l"}
126+
_, userShellName := path.Split(userShellBinPath)
127+
128+
if userShellName == "" {
129+
return errors.New("failed to get the current user's default shell name")
130+
}
131+
132+
command := []string{"/usr/bin/env", userShellName, "-l"}
126133

127134
if err := runCommand(container, defaultContainer, image, release, 0, command, true, true, false); err != nil {
128135
return err

0 commit comments

Comments
 (0)