From 0ec2162aeb2d230f036aa9beddf9e1acff6dcadd Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Sun, 11 Apr 2021 20:18:27 -0400 Subject: [PATCH] Map postprocess command stderr to os.Stderr --- config.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/config.go b/config.go index 2709896..23ff532 100644 --- a/config.go +++ b/config.go @@ -1,7 +1,6 @@ package main import ( - "bytes" "log" "os" "os/exec" @@ -38,13 +37,13 @@ func (t Task) Format(p *Page) (string, []byte) { if t.PostProcess != "" { split := strings.Split(t.PostProcess, " ") cmd := exec.Command(split[0], split[1:]...) - buf := new(bytes.Buffer) cmd.Stdin = strings.NewReader(p.Content) - cmd.Stdout = buf - if err := cmd.Run(); err != nil { + cmd.Stderr = os.Stderr + output, err := cmd.Output() + if err != nil { log.Fatal(err) } - return path, buf.Bytes() + return path, output } return path, []byte(p.Content)