Skip to content

Commit

Permalink
sh.run(): quoted strings before join (#306)
Browse files Browse the repository at this point in the history
* sh.run(): quoted strings before join

Co-authored-by: shouldsee <shouldsee@qq.com>
Co-authored-by: Nate Finch <nate.finch@gmail.com>
  • Loading branch information
3 people authored Dec 14, 2021
1 parent 0c5affe commit 404c119
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions sh/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 404c119

Please sign in to comment.