Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/cmd/enter.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func enter(cmd *cobra.Command, args []string) error {

command := []string{userShell, "-l"}

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

Expand Down
2 changes: 1 addition & 1 deletion src/cmd/rootMigrationPath.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func rootRunImpl(cmd *cobra.Command, args []string) error {

command := []string{userShell, "-l"}

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

Expand Down
16 changes: 15 additions & 1 deletion src/cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ var (
distro string
preserveFDs uint
release string
workDir string
}

runFallbackCommands = [][]string{{"/bin/bash", "-l"}}
Expand Down Expand Up @@ -96,6 +97,12 @@ func init() {
"",
"Run command inside a Toolbx container for a different operating system release than the host")

flags.StringVarP(&runFlags.workDir,
"workdir",
"w",
"",
"Run command inside a Toolbx container within the given working directory.")

runCmd.SetHelpFunc(runHelp)

if err := runCmd.RegisterFlagCompletionFunc("container", completionContainerNames); err != nil {
Expand Down Expand Up @@ -156,6 +163,7 @@ func run(cmd *cobra.Command, args []string) error {
image,
release,
runFlags.preserveFDs,
runFlags.workDir,
command,
false,
false,
Expand All @@ -170,6 +178,7 @@ func runCommand(container string,
defaultContainer bool,
image, release string,
preserveFDs uint,
workDir string,
command []string,
emitEscapeSequence, fallbackToBash, pedantic bool) error {

Expand Down Expand Up @@ -344,6 +353,7 @@ func runCommand(container string,
environ := append(cdiEnviron, p11KitServerEnviron...)
if err := runCommandWithFallbacks(container,
preserveFDs,
workDir,
command,
environ,
emitEscapeSequence,
Expand All @@ -356,6 +366,7 @@ func runCommand(container string,

func runCommandWithFallbacks(container string,
preserveFDs uint,
workDir string,
command, environ []string,
emitEscapeSequence, fallbackToBash bool) error {

Expand Down Expand Up @@ -391,7 +402,10 @@ func runCommandWithFallbacks(container string,

runFallbackCommandsIndex := 0
runFallbackWorkDirsIndex := 0
workDir := workingDirectory

if workDir == "" {
workDir = workingDirectory
}

for {
execArgs := constructExecArgs(container,
Expand Down