github.com/stevenmatthewt/agent@v3.5.4+incompatible/process/run.go (about)

     1  package process
     2  
     3  import (
     4  	"fmt"
     5  	"os/exec"
     6  	"strings"
     7  
     8  	"github.com/buildkite/agent/logger"
     9  )
    10  
    11  func Run(command string, arg ...string) (string, error) {
    12  	output, err := exec.Command(command, arg...).Output()
    13  
    14  	if err != nil {
    15  		logger.Debug("Could not run: %s %s (returned %s) (%T: %v)", command, arg, output, err, err)
    16  		return "", err
    17  	}
    18  
    19  	return strings.Trim(fmt.Sprintf("%s", output), "\n"), nil
    20  }