Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 7 commits into from
Dec 14, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions sh/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,14 @@ 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:=0; i<len(args); i++ {
shouldsee marked this conversation as resolved.
Show resolved Hide resolved
quoted=append(quoted,fmt.Sprintf("\"%s\"",args[i]));
shouldsee marked this conversation as resolved.
Show resolved Hide resolved
}
log.Println("[magefile-exec]:", cmd, strings.Join(quoted, " "))
shouldsee marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down