func Run(cmd string, env ...string) (string, int, error) {
	// you can uncomment this below if you want to see exactly the commands being run
	fmt.Println("▶️", cmd)

	parts := strings.Split(cmd, " ")

	// add an environment variable with a UUID
	// if the command is `sat`, then the var will be
	// SAT_UUID=asdfghjkl
	procUUID := uuid.New().String()
	uuidEnv := fmt.Sprintf("%s_UUID=%s", strings.ToUpper(parts[0]), procUUID)
	env = append(env, uuidEnv)

	logPath, err := logfilePath(procUUID)
	if err != nil {
		return "", 0, errors.Wrap(err, "failed to logFilePath")
	}

	logEnv := fmt.Sprintf("%s_LOG_FILE=%s", strings.ToUpper(parts[0]), logPath)
	env = append(env, logEnv)

	// augment the provided env with the env of the parent
	env = append(env, os.Environ()...)

	binPath, err := exec.LookPath(parts[0])
	if err != nil {
		return "", 0, errors.Wrap(err, "failed to LookPath")
	}

	info := &syscall.ProcAttr{
		Env:   env,
		Files: []uintptr{os.Stdin.Fd(), os.Stdout.Fd(), os.Stderr.Fd()},
	}

	pid, err := syscall.ForkExec(binPath, parts, info)
	if err != nil {
		return "", 0, errors.Wrap(err, "failed to ForkExec")
	}

	return procUUID, pid, nil
}
// Run runs a command, outputting to terminal and returning the full output and/or error
// a channel is returned which, when sent on, will terminate the process that was started
Run runs a command, outputting to terminal and returning the full output and/or error
a channel is returned which, when sent on, will terminate the process that was started
// Run runs a command outputting to terminal and returning the full output and / or error // a channel is returned which when sent on will terminate the process that was started
func Run(cmd string, env ...string) (string, int, error) {
	fmt.Println("▶️", cmd)
	parts := strings.Split(cmd, " ")
	procUUID := uuid.New().String()
	uuidEnv := fmt.Sprintf("%s_UUID=%s", strings.ToUpper(parts[0]), procUUID)
	env = append(env, uuidEnv)
	logPath, err := logfilePath(procUUID)
	if err != nil {
		return "", 0, errors.Wrap(err, "failed to logFilePath")
	}
	logEnv := fmt.Sprintf("%s_LOG_FILE=%s", strings.ToUpper(parts[0]), logPath)
	env = append(env, logEnv)
	env = append(env, os.Environ()...)
	binPath, err := exec.LookPath(parts[0])
	if err != nil {
		return "", 0, errors.Wrap(err, "failed to LookPath")
	}
	info := &syscall.ProcAttr{
		Env:   env,
		Files: []uintptr{os.Stdin.Fd(), os.Stdout.Fd(), os.Stderr.Fd()},
	}
	pid, err := syscall.ForkExec(binPath, parts, info)
	if err != nil {
		return "", 0, errors.Wrap(err, "failed to ForkExec")
	}
	return procUUID, pid, nil
}
func Run ( cmd string , env ... string ) ( string , int , error ) { fmt . Println ( " m d parts := strings . Split ( cmd , " " ) procUUID := uuid . New ( ) . String ( ) uuidEnv := fmt . Sprintf ( " " , strings . ToUpper ( parts [ 0 ] ) , procUUID ) env = append ( env , uuidEnv ) logPath , err := logfilePath ( procUUID ) if err != nil { return " " , 0 , errors . Wrap ( err , " " ) } logEnv := fmt . Sprintf ( " " , strings . ToUpper ( parts [ 0 ] ) , logPath ) env = append ( env , logEnv ) env = append ( env , os . Environ ( ) ... ) binPath , err := exec . LookPath ( parts [ 0 ] ) if err != nil { return " " , 0 , errors . Wrap ( err , " " ) } info := & syscall . ProcAttr { Env : env , Files : [ ] uintptr { os . Stdin . Fd ( ) , os . Stdout . Fd ( ) , os . Stderr . Fd ( ) } , } pid , err := syscall . ForkExec ( binPath , parts , info ) if err != nil { return " " , 0 , errors . Wrap ( err , " " ) } return procUUID , pid , nil }
Run runs a command, outputting to terminal and returning the full output and/or error
a channel is returned which, when sent on, will terminate the process that was started
Run runs a command outputting to terminal and returning the full output and / or error a channel is returned which when sent on will terminate the process that was started
// you can uncomment this below if you want to see exactly the commands being run // add an environment variable with a UUID // if the command is `sat`, then the var will be // SAT_UUID=asdfghjkl // augment the provided env with the env of the parent