From 17de63061672aeac1292c719df3160990db6f9a4 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Mon, 18 Feb 2019 10:58:12 -0800 Subject: [PATCH] use windows Exec on windows --- main.go | 3 +-- main_unix.go | 9 +++++++++ main_windows.go | 9 +++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 main_unix.go create mode 100644 main_windows.go diff --git a/main.go b/main.go index 1631f4a..8bb692d 100644 --- a/main.go +++ b/main.go @@ -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") diff --git a/main_unix.go b/main_unix.go new file mode 100644 index 0000000..80b775e --- /dev/null +++ b/main_unix.go @@ -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) +} diff --git a/main_windows.go b/main_windows.go new file mode 100644 index 0000000..380afa4 --- /dev/null +++ b/main_windows.go @@ -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) +}