cmd/run: Launch command with stderr being attached

Without stderr being attached stderr output of the invoked command goes
into stdout.

Behaviour before:
; output="$(toolbox run /etc)"
Error: failed to invoke command /etc in container <name-of-container>
; echo -e "$output"
/bin/sh: line 1: /etc: Is a directory
/bin/sh: line 1: exec: /etc: cannot execute: Is a directory

Behaviour after:
; output="$(toolbox run /etc)"
/bin/sh: line 1: /etc: Is a directory
/bin/sh: line 1: exec: /etc: cannot execute: Is a directory
Error: failed to invoke command /etc in container <name-of-container>
; echo -e "$output"

https://github.com/containers/toolbox/pull/1013
This commit is contained in:
Ondřej Míchal 2022-03-20 21:22:00 +02:00
parent a22d7821cb
commit 7cba807e45

View file

@ -325,7 +325,7 @@ func runCommandWithFallbacks(container string, command []string, emitEscapeSeque
logrus.Debugf("%s", arg)
}
exitCode, err := shell.RunWithExitCode("podman", os.Stdin, os.Stdout, nil, execArgs...)
exitCode, err := shell.RunWithExitCode("podman", os.Stdin, os.Stdout, os.Stderr, execArgs...)
if emitEscapeSequence {
fmt.Printf("\033]777;container;pop;;;%s\033\\", currentUser.Uid)