Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions src/cmd/enter.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"os"
"path"

"github.com/containers/toolbox/pkg/utils"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions src/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ var (
preserveFDs uint
release string
}

runFallbackCommands = [][]string{{"/bin/bash", "-l"}}
runFallbackCommands = [][]string{{"/usr/bin/env", "sh", "-l"}}
runFallbackWorkDirs = []string{"" /* $HOME */}
)

Expand Down