MCPcopy Index your code
hub / github.com/micro-editor/micro / ExecCommand

Function ExecCommand

internal/shell/shell.go:19–32  ·  view source on GitHub ↗

ExecCommand executes a command using exec It returns any output/errors

(name string, arg ...string)

Source from the content-addressed store, hash-verified

17// ExecCommand executes a command using exec
18// It returns any output/errors
19func ExecCommand(name string, arg ...string) (string, error) {
20 var err error
21 cmd := exec.Command(name, arg...)
22 outputBytes := &bytes.Buffer{}
23 cmd.Stdout = outputBytes
24 cmd.Stderr = outputBytes
25 err = cmd.Start()
26 if err != nil {
27 return "", err
28 }
29 err = cmd.Wait() // wait for command to finish
30 outstring := outputBytes.String()
31 return outstring, err
32}
33
34// RunCommand executes a shell command and returns the output/error
35func RunCommand(input string) (string, error) {

Callers 1

RunCommandFunction · 0.85

Calls 2

StartMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected