summaryrefslogtreecommitdiff
path: root/src/cmd/hgpatch
diff options
context:
space:
mode:
authorOndřej Surý <ondrej@sury.org>2011-08-03 16:54:30 +0200
committerOndřej Surý <ondrej@sury.org>2011-08-03 16:54:30 +0200
commit28592ee1ea1f5cdffcf85472f9de0285d928cf12 (patch)
tree32944e18b23f7fe4a0818a694aa2a6dfb1835463 /src/cmd/hgpatch
parente836bee4716dc0d4d913537ad3ad1925a7ac32d0 (diff)
downloadgolang-upstream/59.tar.gz
Imported Upstream version 59upstream/59
Diffstat (limited to 'src/cmd/hgpatch')
-rw-r--r--src/cmd/hgpatch/main.go18
1 files changed, 7 insertions, 11 deletions
diff --git a/src/cmd/hgpatch/main.go b/src/cmd/hgpatch/main.go
index 8ee3422e2..4f7aec22b 100644
--- a/src/cmd/hgpatch/main.go
+++ b/src/cmd/hgpatch/main.go
@@ -176,7 +176,7 @@ func main() {
list[i] = f
i++
}
- sort.SortStrings(list)
+ sort.Strings(list)
for _, f := range list {
fmt.Printf("%s\n", f)
}
@@ -282,7 +282,7 @@ func hgModified() ([]string, os.Error) {
if err != nil {
return nil, err
}
- return strings.Split(strings.TrimSpace(out), "\n", -1), nil
+ return strings.Split(strings.TrimSpace(out), "\n"), nil
}
// hgAdd adds name to the repository.
@@ -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.