mirror of
https://github.com/golang/go
synced 2024-11-22 01:04:40 -07:00
gobuilder: remove some windows-specificity
R=alex.brainman CC=golang-dev https://golang.org/cl/4528109
This commit is contained in:
parent
3fbd478a8a
commit
55f8fd2684
@ -10,7 +10,6 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -19,10 +18,7 @@ func run(envv []string, dir string, argv ...string) os.Error {
|
|||||||
if *verbose {
|
if *verbose {
|
||||||
log.Println("run", argv)
|
log.Println("run", argv)
|
||||||
}
|
}
|
||||||
if runtime.GOOS == "windows" && isBash(argv[0]) {
|
argv = useBash(argv)
|
||||||
// shell script cannot be executed directly on Windows.
|
|
||||||
argv = append([]string{"bash", "-c"}, argv...)
|
|
||||||
}
|
|
||||||
bin, err := lookPath(argv[0])
|
bin, err := lookPath(argv[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -41,10 +37,7 @@ func runLog(envv []string, logfile, dir string, argv ...string) (output string,
|
|||||||
if *verbose {
|
if *verbose {
|
||||||
log.Println("runLog", argv)
|
log.Println("runLog", argv)
|
||||||
}
|
}
|
||||||
if runtime.GOOS == "windows" && isBash(argv[0]) {
|
argv = useBash(argv)
|
||||||
// shell script cannot be executed directly on Windows.
|
|
||||||
argv = append([]string{"bash", "-c"}, argv...)
|
|
||||||
}
|
|
||||||
bin, err := lookPath(argv[0])
|
bin, err := lookPath(argv[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
@ -84,8 +77,12 @@ func lookPath(cmd string) (string, os.Error) {
|
|||||||
return exec.LookPath(cmd)
|
return exec.LookPath(cmd)
|
||||||
}
|
}
|
||||||
|
|
||||||
// isBash determines if name refers to a shell script.
|
// useBash prefixes a list of args with 'bash' if the first argument
|
||||||
func isBash(name string) bool {
|
// is a bash script.
|
||||||
// TODO(brainman): perhaps it is too simple and needs better check.
|
func useBash(argv []string) []string {
|
||||||
return strings.HasSuffix(name, ".bash")
|
// TODO(brainman): choose a more reliable heuristic here.
|
||||||
|
if strings.HasSuffix(argv[0], ".bash") {
|
||||||
|
argv = append([]string{"bash"}, argv...)
|
||||||
|
}
|
||||||
|
return argv
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user