MCPcopy Index your code
hub / github.com/docker/docker-agent / ExecWithContextInDir

Function ExecWithContextInDir

e2e/binary/shellout.go:27–36  ·  view source on GitHub ↗
(ctx context.Context, dir, cmd string, args, env []string)

Source from the content-addressed store, hash-verified

25}
26
27func ExecWithContextInDir(ctx context.Context, dir, cmd string, args, env []string) (CmdResult, error) {
28 command := exec.CommandContext(ctx, cmd, args...)
29 command.Dir = dir
30 command.Env = append(os.Environ(), env...)
31 res, err := runCmd(command)
32 if err != nil {
33 return res, fmt.Errorf("executing '%s %s' : %s: %s", cmd, strings.Join(args, " "), err.Error(), res.Stdout+"\n"+res.Stderr)
34 }
35 return res, nil
36}
37
38func runCmd(c *exec.Cmd) (CmdResult, error) {
39 if c.Stdout != nil {

Callers 2

ExecWithContextFunction · 0.85
ExecWithContextAndEnvFunction · 0.85

Calls 2

runCmdFunction · 0.70
ErrorMethod · 0.45

Tested by

no test coverage detected