Commit 55f8fd26 authored by Andrew Gerrand's avatar Andrew Gerrand

gobuilder: remove some windows-specificity

R=alex.brainman
CC=golang-dev
https://golang.org/cl/4528109
parent 3fbd478a
...@@ -10,7 +10,6 @@ import ( ...@@ -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 { ...@@ -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, ...@@ -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) { ...@@ -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
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment