1
0
mirror of https://github.com/magefile/mage.git synced 2026-10-24 06:19:18 +03:00

sh.run(): quoted strings before join (#306)

* sh.run(): quoted strings before join

Co-authored-by: shouldsee <shouldsee@qq.com>
Co-authored-by: Nate Finch <nate.finch@gmail.com>
This commit is contained in:
shouldsee
2021-12-14 23:07:02 +08:00
committed by GitHub
parent 0c5affe599
commit 404c119a58

View File

@@ -132,11 +132,15 @@ func run(env map[string]string, stdout, stderr io.Writer, cmd string, args ...st
c.Stderr = stderr
c.Stdout = stdout
c.Stdin = os.Stdin
log.Println("exec:", cmd, strings.Join(args, " "))
var quoted []string
for i := range args {
quoted = append(quoted, fmt.Sprintf("%q", args[i]));
}
log.Println("exec:", cmd, strings.Join(quoted, " "))
err = c.Run()
return CmdRan(err), ExitStatus(err), err
}
// CmdRan examines the error to determine if it was generated as a result of a
// command running via os/exec.Command. If the error is nil, or the command ran
// (even if it exited with a non-zero exit code), CmdRan reports true. If the