MCPcopy Index your code
hub / github.com/ddev/ddev / RunHostCommandWithOptions

Function RunHostCommandWithOptions

pkg/exec/exec.go:153–174  ·  view source on GitHub ↗

RunHostCommandWithOptions executes a command on the host with configurable options and returns the combined stdout/stderr results and error

(command string, options []CmdOption, args ...string)

Source from the content-addressed store, hash-verified

151// RunHostCommandWithOptions executes a command on the host with configurable options
152// and returns the combined stdout/stderr results and error
153func RunHostCommandWithOptions(command string, options []CmdOption, args ...string) (string, error) {
154 if globalconfig.DdevVerbose {
155 output.UserOut.Printf("RunHostCommandWithOptions: %s %s", command, strings.Join(args, " "))
156 }
157 c := HostCommand(command, args...)
158
159 // Apply all options
160 for _, option := range options {
161 option(c)
162 }
163 // Default to os.Stdin if no stdin was set
164 if c.Stdin == nil {
165 c.Stdin = os.Stdin
166 }
167
168 o, err := c.CombinedOutput()
169 if globalconfig.DdevVerbose {
170 output.UserOut.Printf("RunHostCommandWithOptions returned output=%v err=%v", string(o), err)
171 }
172
173 return string(o), err
174}
175
176// RunHostCommandSeparateStreams executes a command on the host and returns the
177// stdout and error

Callers 3

StopMutagenDaemonFunction · 0.92
TestCmdAuthSSHFunction · 0.92

Calls 1

HostCommandFunction · 0.85

Tested by 2

TestCmdAuthSSHFunction · 0.74