Exemplo n.º 1
0
func (n NodeCommand) execExternal(scp *variables.Scope, ioc *T.IOContainer, args []string) T.ExitStatus {
	// This is needed so that pipes will terminate
	if pw, isPipeWriter := ioc.Out.(*io.PipeWriter); isPipeWriter {
		defer func() {
			if err := pw.Close(); err != nil {
				panic(err) // XXX: Print error to stdout and continue?
			}
		}()
	}

	cmd := exec.Command(args[0], args[1:]...)
	cmd.Env = scp.Environ()
	cmd.Stdin = ioc.In
	cmd.Stderr = ioc.Err
	cmd.Stdout = ioc.Out

	err := cmd.Run()
	if err == nil {
		return T.ExitSuccess
	}
	return T.ExitFailure
}