From 5bac0b264333bdf0f4680ea281ebca0ad0bdb2fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paulo=20Sima=CC=83o?= Date: Mon, 25 Oct 2021 19:05:17 -0300 Subject: [PATCH] added trace --- lib.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib.go b/lib.go index e20117b..a1700ec 100644 --- a/lib.go +++ b/lib.go @@ -8,6 +8,7 @@ import ( "os/exec" "path/filepath" "runtime" + "runtime/debug" "strings" ) @@ -49,6 +50,7 @@ const ( // Opts.SetupProc will customize the processes before execution - Eg.: setting out and err type Opts struct { Debug bool + Trace bool Await bool Wd string SetupProc func(cmd *exec.Cmd) @@ -227,6 +229,11 @@ func Exec(str string, opts ...*Opts) ([]*exec.Cmd, error) { } } + if opt.Trace { + bs := debug.Stack() + log.Printf("Running: %s\n%s", str, string(bs)) + } + cmdwd := opt.Wd prepCmd := func(l Line) *exec.Cmd {