Unchecked executes a command and process the information
(command string)
| 36 | |
| 37 | // Unchecked executes a command and process the information |
| 38 | func Unchecked(command string) (stdout string, stderr string, err error) { |
| 39 | tokens, err := shlex.Split(command) |
| 40 | if err != nil { |
| 41 | ginkgo.GinkgoWriter.Printf("Error parsing command `%v`: %v\n", command, err) |
| 42 | return "", "", err |
| 43 | } |
| 44 | |
| 45 | var outBuffer, errBuffer bytes.Buffer |
| 46 | cmd := exec.Command(tokens[0], tokens[1:]...) // #nosec G204 |
| 47 | cmd.Stdout, cmd.Stderr = &outBuffer, &errBuffer |
| 48 | err = cmd.Run() |
| 49 | stdout = outBuffer.String() |
| 50 | stderr = errBuffer.String() |
| 51 | if err != nil { |
| 52 | err = fmt.Errorf("%w - %v", err, stderr) |
| 53 | } |
| 54 | return stdout, stderr, err |
| 55 | } |
| 56 | |
| 57 | // UncheckedRetry executes a command and process the information with retry |
| 58 | func UncheckedRetry(command string) (stdout string, stderr string, err error) { |