1
0
mirror of https://github.com/golang/go synced 2024-11-13 18:10:24 -07:00

cmd/go: connect os.Stdin for go run

Fixes #2875

R=golang-dev, r, rsc
CC=golang-dev
https://golang.org/cl/5641052
This commit is contained in:
Brad Fitzpatrick 2012-02-08 16:30:28 +11:00
parent 3f6a517db6
commit 878608bd29

View File

@ -7,6 +7,7 @@ package main
import ( import (
"fmt" "fmt"
"os" "os"
"os/exec"
"strings" "strings"
) )
@ -61,6 +62,19 @@ func (b *builder) runProgram(a *action) error {
return nil return nil
} }
} }
run(a.deps[0].target, a.args)
runStdin(a.deps[0].target, a.args)
return nil return nil
} }
// runStdin is like run, but connects Stdin.
func runStdin(cmdargs ...interface{}) {
cmdline := stringList(cmdargs...)
cmd := exec.Command(cmdline[0], cmdline[1:]...)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
if err := cmd.Run(); err != nil {
errorf("%v", err)
}
}