mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
misc/dashboard/builder: -cmd for user-specified build command
R=rsc CC=golang-dev https://golang.org/cl/2248043
This commit is contained in:
parent
a071853015
commit
96d6f9dea4
2 changed files with 14 additions and 13 deletions
|
|
@ -4,11 +4,12 @@ import (
|
|||
"bytes"
|
||||
"exec"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// run is a simple wrapper for exec.Run/Close
|
||||
func run(envv []string, dir string, argv ...string) os.Error {
|
||||
bin, err := exec.LookPath(argv[0])
|
||||
bin, err := pathLookup(argv[0])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
@ -22,7 +23,7 @@ func run(envv []string, dir string, argv ...string) os.Error {
|
|||
|
||||
// runLog runs a process and returns the combined stdout/stderr
|
||||
func runLog(envv []string, dir string, argv ...string) (output string, exitStatus int, err os.Error) {
|
||||
bin, err := exec.LookPath(argv[0])
|
||||
bin, err := pathLookup(argv[0])
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
@ -43,3 +44,11 @@ func runLog(envv []string, dir string, argv ...string) (output string, exitStatu
|
|||
}
|
||||
return b.String(), w.WaitStatus.ExitStatus(), nil
|
||||
}
|
||||
|
||||
// Find bin in PATH if a relative or absolute path hasn't been specified
|
||||
func pathLookup(s string) (string, os.Error) {
|
||||
if strings.HasPrefix(s, "/") || strings.HasPrefix(s, "./") || strings.HasPrefix(s, "../") {
|
||||
return s, nil
|
||||
}
|
||||
return exec.LookPath(s)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue