use unix.Exec instead of syscall.Exec

This commit is contained in:
Kevin Burke 2018-03-19 09:00:14 -07:00
parent 5b9795d676
commit e86e26c4bc
No known key found for this signature in database
GPG Key ID: 24B0EF06511BA263
1 changed files with 5 additions and 3 deletions

View File

@ -10,12 +10,12 @@ import (
"os" "os"
"os/exec" "os/exec"
"strings" "strings"
"syscall"
"github.com/alecthomas/chroma" "github.com/alecthomas/chroma"
"github.com/alecthomas/chroma/formatters/html" "github.com/alecthomas/chroma/formatters/html"
"github.com/alecthomas/chroma/lexers" "github.com/alecthomas/chroma/lexers"
"github.com/alecthomas/chroma/styles" "github.com/alecthomas/chroma/styles"
"golang.org/x/sys/unix"
) )
// dataPipedIn returns true if the user piped data via stdin. // dataPipedIn returns true if the user piped data via stdin.
@ -132,7 +132,6 @@ func main() {
} }
} }
checkError(bs.Err(), "reading markdown file") checkError(bs.Err(), "reading markdown file")
_ = needCSS
f, err := ioutil.TempFile("", "chroma-markdown-") f, err := ioutil.TempFile("", "chroma-markdown-")
checkError(err, "creating temporary file") checkError(err, "creating temporary file")
w := bufio.NewWriter(f) w := bufio.NewWriter(f)
@ -149,6 +148,9 @@ func main() {
cmark, lookErr = exec.LookPath("markdown") cmark, lookErr = exec.LookPath("markdown")
checkError(lookErr, "finding markdown binary") checkError(lookErr, "finding markdown binary")
} }
execErr := syscall.Exec(cmark, []string{cmark, f.Name()}, []string{}) execErr := unix.Exec(cmark, []string{cmark, f.Name()}, []string{})
checkError(execErr, "executing markdown binary") checkError(execErr, "executing markdown binary")
if err := f.Close(); err != nil {
checkError(err, "closing file")
}
} }