Skip to content

Commit

Permalink
dev: make sure we inherit stdout and stderr when appropriate
Browse files Browse the repository at this point in the history
Otherwise `bazel build`/`test` output will be ugly (won't be colored/
use `ncurses`/etc.)

Release note: None
  • Loading branch information
rickystewart committed Feb 25, 2022
1 parent 0679c4c commit 11e09c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dev
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -euo pipefail

# Bump this counter to force rebuilding `dev` on all machines.
DEV_VERSION=18
DEV_VERSION=19

THIS_DIR=$(cd "$(dirname "$0")" && pwd)
BINARY_DIR=$THIS_DIR/bin/dev-versions
Expand Down
9 changes: 6 additions & 3 deletions pkg/cmd/dev/io/exec/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,14 @@ func (e *Exec) commandContextInheritingStdStreamsImpl(
}
e.logger.Print(command)

_, err := e.Next(command, func(outTrace, errTrace io.Writer) (string, error) {
_, err := e.Next(command, func(_, _ io.Writer) (string, error) {
cmd := exec.CommandContext(ctx, name, args...)
// NB: In this function we specifically want to inherit the
// standard IO streams, so we are not going to capture the
// `outTrace` or `errTrace`.
cmd.Stdin = os.Stdin
cmd.Stdout = io.MultiWriter(e.stdout, outTrace)
cmd.Stderr = io.MultiWriter(e.stderr, errTrace)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Dir = e.dir
cmd.Env = env

Expand Down

0 comments on commit 11e09c3

Please sign in to comment.