mirror of
https://github.com/fleetdm/fleet
synced 2026-04-27 00:17:21 +00:00
21 lines
454 B
Go
21 lines
454 B
Go
package update
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
)
|
|
|
|
var _ = runCmdCollectErr // just to avoid unused errors on non-darwin platforms
|
|
|
|
func runCmdCollectErr(exe string, args ...string) error {
|
|
cmd := exec.Command(exe, args...)
|
|
out, err := cmd.CombinedOutput()
|
|
if err != nil && len(out) > 0 {
|
|
// just as a precaution, limit the length of the output
|
|
if len(out) > 512 {
|
|
out = out[:512]
|
|
}
|
|
err = fmt.Errorf("%w: %s", err, string(out))
|
|
}
|
|
return err
|
|
}
|