]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/gofmt: fix diff on Plan 9
authorDavid du Colombier <0intro@gmail.com>
Wed, 8 Feb 2017 22:11:15 +0000 (23:11 +0100)
committerDavid du Colombier <0intro@gmail.com>
Wed, 8 Feb 2017 22:29:33 +0000 (22:29 +0000)
On Plan 9, GNU diff is called ape/diff.

Fixes #18999.

Change-Id: I7cf6c23c97bcc47172bbf838fd9dd72aefa4c18b
Reviewed-on: https://go-review.googlesource.com/36650
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/cmd/gofmt/gofmt.go

index cf1ddea917cfd5d94f672742c960148ad1b31b14..ff38df7ee4e5841a916e16d0f95c7bf73166c235 100644 (file)
@@ -243,7 +243,12 @@ func diff(b1, b2 []byte, filename string) (data []byte, err error) {
        f1.Write(b1)
        f2.Write(b2)
 
-       data, err = exec.Command("diff", "-u", f1.Name(), f2.Name()).CombinedOutput()
+       cmd := "diff"
+       if runtime.GOOS == "plan9" {
+               cmd = "/bin/ape/diff"
+       }
+
+       data, err = exec.Command(cmd, "-u", f1.Name(), f2.Name()).CombinedOutput()
        if len(data) > 0 {
                // diff exits with a non-zero status when the files don't match.
                // Ignore that failure as long as we get output.