LEFT | RIGHT |
| 1 // Copyright 2011 The Go Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style |
| 3 // license that can be found in the LICENSE file. |
| 4 |
1 package main | 5 package main |
2 | 6 |
3 import ( | 7 import ( |
4 "bytes" | 8 "bytes" |
5 "exec" | 9 "exec" |
6 "io" | 10 "io" |
7 "log" | 11 "log" |
8 "os" | 12 "os" |
9 "strings" | 13 "strings" |
10 ) | 14 ) |
(...skipping 12 matching lines...) Expand all Loading... |
23 if err != nil { | 27 if err != nil { |
24 return err | 28 return err |
25 } | 29 } |
26 return p.Close() | 30 return p.Close() |
27 } | 31 } |
28 | 32 |
29 // runLog runs a process and returns the combined stdout/stderr,· | 33 // runLog runs a process and returns the combined stdout/stderr,· |
30 // as well as writing it to logfile (if specified). | 34 // as well as writing it to logfile (if specified). |
31 func runLog(envv []string, logfile, dir string, argv ...string) (output string,
exitStatus int, err os.Error) { | 35 func runLog(envv []string, logfile, dir string, argv ...string) (output string,
exitStatus int, err os.Error) { |
32 if *verbose { | 36 if *verbose { |
33 » » log.Println("run", argv) | 37 » » log.Println("runLog", argv) |
34 } | 38 } |
35 bin, err := pathLookup(argv[0]) | 39 bin, err := pathLookup(argv[0]) |
36 if err != nil { | 40 if err != nil { |
37 return | 41 return |
38 } | 42 } |
39 p, err := exec.Run(bin, argv, envv, dir, | 43 p, err := exec.Run(bin, argv, envv, dir, |
40 exec.DevNull, exec.Pipe, exec.MergeWithStdout) | 44 exec.DevNull, exec.Pipe, exec.MergeWithStdout) |
41 if err != nil { | 45 if err != nil { |
42 return | 46 return |
43 } | 47 } |
(...skipping 19 matching lines...) Expand all Loading... |
63 return b.String(), wait.WaitStatus.ExitStatus(), nil | 67 return b.String(), wait.WaitStatus.ExitStatus(), nil |
64 } | 68 } |
65 | 69 |
66 // Find bin in PATH if a relative or absolute path hasn't been specified | 70 // Find bin in PATH if a relative or absolute path hasn't been specified |
67 func pathLookup(s string) (string, os.Error) { | 71 func pathLookup(s string) (string, os.Error) { |
68 if strings.HasPrefix(s, "/") || strings.HasPrefix(s, "./") || strings.Ha
sPrefix(s, "../") { | 72 if strings.HasPrefix(s, "/") || strings.HasPrefix(s, "./") || strings.Ha
sPrefix(s, "../") { |
69 return s, nil | 73 return s, nil |
70 } | 74 } |
71 return exec.LookPath(s) | 75 return exec.LookPath(s) |
72 } | 76 } |
LEFT | RIGHT |