summaryrefslogtreecommitdiff
path: root/src/cmd/hgpatch/main.go
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-06-28 15:28:34 +0200
committerOndřej Surý <ondrej@sury.org>2011-06-28 15:28:34 +0200
commit8d00b02d82d86abe51773dc2c1751843bb538ae5 (patch)
tree6656d166a046fc751548e88f071fedbeb9355443 /src/cmd/hgpatch/main.go
parentc29cace1e8f3260389ea78fa4ef86d80cd5e5275 (diff)
downloadgolang-8d00b02d82d86abe51773dc2c1751843bb538ae5.tar.gz
Imported Upstream version 2011.06.23upstream-weekly/2011.06.23
Diffstat (limited to 'src/cmd/hgpatch/main.go')
-rw-r--r--src/cmd/hgpatch/main.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/cmd/hgpatch/main.go b/src/cmd/hgpatch/main.go
index 8ee3422e2..1f3e5e736 100644
--- a/src/cmd/hgpatch/main.go
+++ b/src/cmd/hgpatch/main.go
@@ -329,15 +329,14 @@ var lookPathCache = make(map[string]string)
// It provides input on standard input to the command.
func run(argv []string, input []byte) (out string, err os.Error) {
if len(argv) < 1 {
- err = os.EINVAL
- goto Error
+ return "", &runError{dup(argv), os.EINVAL}
}
prog, ok := lookPathCache[argv[0]]
if !ok {
prog, err = exec.LookPath(argv[0])
if err != nil {
- goto Error
+ return "", &runError{dup(argv), err}
}
lookPathCache[argv[0]] = prog
}
@@ -347,13 +346,10 @@ func run(argv []string, input []byte) (out string, err os.Error) {
cmd.Stdin = bytes.NewBuffer(input)
}
bs, err := cmd.CombinedOutput()
- if err == nil {
- return string(bs), nil
+ if err != nil {
+ return "", &runError{dup(argv), err}
}
-
-Error:
- err = &runError{dup(argv), err}
- return
+ return string(bs), nil
}
// A runError represents an error that occurred while running a command.