From: Russ Cox Date: Fri, 23 Jan 2015 16:08:51 +0000 (-0500) Subject: [dev.cc] cmd/dist: show bootstrap build progress in real time X-Git-Tag: go1.5beta1~1915^2~95 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=07a27ce09ea01c1939389d5f5e1d3414fc893882;p=gostls13.git [dev.cc] cmd/dist: show bootstrap build progress in real time Change-Id: I97bbf7a276c8f99554f0e3a9bcc8d3792a5e0f65 Reviewed-on: https://go-review.googlesource.com/3221 Reviewed-by: Brad Fitzpatrick --- diff --git a/src/cmd/dist/util.go b/src/cmd/dist/util.go index 1bb3ba80e6..decbb0ffd2 100644 --- a/src/cmd/dist/util.go +++ b/src/cmd/dist/util.go @@ -84,8 +84,23 @@ func run(dir string, mode int, cmd ...string) string { xcmd := exec.Command(cmd[0], cmd[1:]...) xcmd.Dir = dir + var data []byte var err error - data, err := xcmd.CombinedOutput() + + // If we want to show command output and this is not + // a background command, assume it's the only thing + // running, so we can just let it write directly stdout/stderr + // as it runs without fear of mixing the output with some + // other command's output. Not buffering lets the output + // appear as it is printed instead of once the command exits. + // This is most important for the invocation of 'go1.4 build -v bootstrap/...'. + if mode&(Background|ShowOutput) == ShowOutput { + xcmd.Stdout = os.Stdout + xcmd.Stderr = os.Stderr + err = xcmd.Run() + } else { + data, err = xcmd.CombinedOutput() + } if err != nil && mode&CheckExit != 0 { outputLock.Lock() if len(data) > 0 {