Skip to content

Commit

Permalink
Pass Stderr of hook command to os.Stderr
Browse files Browse the repository at this point in the history
Also keep Stdout instead of silently redirecting to /dev/null.
Print hook error message to os.Stderr.
  • Loading branch information
juergenhoetzel committed Jan 30, 2021
1 parent ff7ed3f commit 9e74432
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hook/hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ func Run(client *openpomodoro.Client, name string) error {
}

cmd := exec.Command(filename)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Env = os.Environ()
if output, err := cmd.Output(); err != nil {
fmt.Printf("Hook %q failed:\n%s\n\n", name, output)
if err := cmd.Run(); err != nil {
fmt.Fprintf(os.Stderr, "Hook %q failed:\n\n", name)
return err
}

Expand Down

0 comments on commit 9e74432

Please sign in to comment.