Skip to content

Commit 67cbb43

Browse files
authored
Redirecting all stdout of subcommands to stderr (bazel-contrib#2656)
go tool compile writes syntax errors to stdout, including the one reported in bazel-contrib#2592. Meanwhile, all regular output of subcommands should have been written to files. We should direct all stdout of subcommands to stderr, so we can find all errors in stderr. This mirrors behavior in the go command
1 parent b4c392f commit 67cbb43

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

go/tools/builders/env.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ func (e *env) goCmd(cmd string, args ...string) []string {
131131
// environment from this process.
132132
func (e *env) runCommand(args []string) error {
133133
cmd := exec.Command(args[0], args[1:]...)
134-
cmd.Stdout = os.Stdout
134+
// Redirecting stdout to stderr. This mirrors behavior in the go command:
135+
// https://go.googlesource.com/go/+/refs/tags/go1.15.2/src/cmd/go/internal/work/exec.go#1958
136+
cmd.Stdout = os.Stderr
135137
cmd.Stderr = os.Stderr
136138
return runAndLogCommand(cmd, e.verbose)
137139
}

0 commit comments

Comments
 (0)