From 7ef979d9f38d7374328c3d9c18c58e5e4abd3c15 Mon Sep 17 00:00:00 2001 From: Viktor Voltaire Date: Thu, 23 Dec 2021 10:54:17 +0100 Subject: [PATCH] chore: wrap log.Println in cmd with verbose check --- sh/cmd.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sh/cmd.go b/sh/cmd.go index 87bb37e6..55ace402 100644 --- a/sh/cmd.go +++ b/sh/cmd.go @@ -137,7 +137,10 @@ func run(env map[string]string, stdout, stderr io.Writer, cmd string, args ...st for i := range args { quoted = append(quoted, fmt.Sprintf("%q", args[i])); } - log.Println("exec:", cmd, strings.Join(quoted, " ")) + // To protect against logging from doing exec in global variables + if os.Getenv(mg.VerboseEnv) == "1" { + log.Println("exec:", cmd, strings.Join(quoted, " ")) + } err = c.Run() return CmdRan(err), ExitStatus(err), err }