use windows Exec on windows

This commit is contained in:
Kevin Burke 2019-02-18 10:58:12 -08:00
parent 822a1431bb
commit 17de630616
No known key found for this signature in database
GPG Key ID: 24B0EF06511BA263
3 changed files with 19 additions and 2 deletions

View File

@ -15,7 +15,6 @@ import (
"github.com/alecthomas/chroma/formatters/html"
"github.com/alecthomas/chroma/lexers"
"github.com/alecthomas/chroma/styles"
"golang.org/x/sys/unix"
)
// dataPipedIn returns true if the user piped data via stdin.
@ -148,7 +147,7 @@ func main() {
cmark, lookErr = exec.LookPath("markdown")
checkError(lookErr, "finding markdown binary")
}
execErr := unix.Exec(cmark, []string{cmark, f.Name()}, []string{})
execErr := localExec(cmark, []string{cmark, f.Name()}, []string{})
checkError(execErr, "executing markdown binary")
if err := f.Close(); err != nil {
checkError(err, "closing file")

9
main_unix.go Normal file
View File

@ -0,0 +1,9 @@
//+build !windows
package main
import "golang.org/x/sys/unix"
func localExec(argv0 string, argv []string, envv []string) error {
return unix.Exec(argv0, argv, envv)
}

9
main_windows.go Normal file
View File

@ -0,0 +1,9 @@
//+build windows
package main
import "golang.org/x/sys/windows"
func localExec(argv0 string, argv []string, envv []string) error {
return windows.Exec(argv0, argv, envv)
}