summaryrefslogtreecommitdiff
path: root/misc/goplay
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-06-30 15:34:22 +0200
committerOndřej Surý <ondrej@sury.org>2011-06-30 15:34:22 +0200
commitd39f5aa373a4422f7a5f3ee764fb0f6b0b719d61 (patch)
tree1833f8b72a4b3a8f00d0d143b079a8fcad01c6ae /misc/goplay
parent8652e6c371b8905498d3d314491d36c58d5f68d5 (diff)
downloadgolang-upstream/58.tar.gz
Imported Upstream version 58upstream/58
Diffstat (limited to 'misc/goplay')
-rw-r--r--misc/goplay/goplay.go28
1 files changed, 1 insertions, 27 deletions
diff --git a/misc/goplay/goplay.go b/misc/goplay/goplay.go
index f3e2ff565..f1dc1bca5 100644
--- a/misc/goplay/goplay.go
+++ b/misc/goplay/goplay.go
@@ -5,7 +5,6 @@
package main
import (
- "bytes"
"exec"
"flag"
"http"
@@ -140,32 +139,7 @@ func error(w http.ResponseWriter, out []byte, err os.Error) {
// run executes the specified command and returns its output and an error.
func run(cmd ...string) ([]byte, os.Error) {
- // find the specified binary
- bin, err := exec.LookPath(cmd[0])
- if err != nil {
- // report binary as well as the error
- return nil, os.NewError(cmd[0] + ": " + err.String())
- }
-
- // run the binary and read its combined stdout and stderr into a buffer
- p, err := exec.Run(bin, cmd, os.Environ(), "", exec.DevNull, exec.Pipe, exec.MergeWithStdout)
- if err != nil {
- return nil, err
- }
- var buf bytes.Buffer
- io.Copy(&buf, p.Stdout)
- w, err := p.Wait(0)
- p.Close()
- if err != nil {
- return nil, err
- }
-
- // set the error return value if the program had a non-zero exit status
- if !w.Exited() || w.ExitStatus() != 0 {
- err = os.ErrorString("running " + cmd[0] + ": " + w.String())
- }
-
- return buf.Bytes(), err
+ return exec.Command(cmd[0], cmd[1:]...).CombinedOutput()
}
var frontPage, output *template.Template // HTML templates