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:
parent
3f6a517db6
commit
878608bd29
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user