From 7fc103fadff43d22530c3e8de651463d3c1f7f95 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Fri, 19 Oct 2018 15:33:30 +0800 Subject: [PATCH] add trace command. Signed-off-by: Bo-Yi Wu --- plugin.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/plugin.go b/plugin.go index 4413b2e..793038f 100644 --- a/plugin.go +++ b/plugin.go @@ -136,16 +136,21 @@ func (p *Plugin) Exec() error { } } - for _, c := range commands { - c.Stdout = os.Stdout - c.Stderr = os.Stderr - c.Env = os.Environ() + for _, cmd := range commands { + cmd.Stdout = os.Stdout + cmd.Stderr = os.Stderr + cmd.Env = os.Environ() - err := c.Run() - if err != nil { + trace(cmd) + + if err := cmd.Run(); err != nil { return err } } return nil } + +func trace(cmd *exec.Cmd) { + fmt.Println("$", strings.Join(cmd.Args, " ")) +}