// Stderr specify the process's standard output and error.
//
// If Stdout and Stderr are the same writer, at most one
// goroutine at a time will call Write.
427019
func Stderr(val io.Writer) OptionSet {
	return func(o *Options) {
		o.Stderr = val
	}
}
722059
func Stdout(val io.Writer) OptionSet {
	return func(o *Options) {
		o.Stdout = val
	}
}
146871
func RunCommandWithStdoutStderr(cmd *exec.Cmd) (bytes.Buffer, bytes.Buffer, error) {
	var stdout, stderr bytes.Buffer
	stderrPipe, err := cmd.StderrPipe()
	stdoutPipe, err := cmd.StdoutPipe()

	cmd.Env = os.Environ()
	if err != nil {
		fmt.Println("error at io pipes")
	}

	err = cmd.Start()
	if err != nil {
		fmt.Println("error at command start")
	}

	go func() {
		streamOutput(stdoutPipe, &stdout, os.Stdout)
	}()
	go func() {
		streamOutput(stderrPipe, &stderr, os.Stderr)
	}()
	err = cmd.Wait()
	if err != nil {
		fmt.Println("error at command wait")
	}
	return stdout, stderr, err
}
1036240
func Warn(err error, format string, a ...interface{}) (int, error) {
	format += ": %v\n"
	a = append(a, err)
	return fmt.Fprintf(os.Stderr, format, a...)
}
434412
func (z *bufioEncWriter) flushErr() (err error) {
	n, err := z.w.Write(z.buf[:z.n])
	z.n -= n
	if z.n > 0 && err == nil {
		err = io.ErrShortWrite
	}
	if n > 0 && z.n > 0 {
		copy(z.buf, z.buf[n:z.n+n])
	}
	return err
}
563979
func (p *Parser) Err() error {
	if p.err != nil {
		return p.err
	}
	return p.l.Err()
}
262211
func StdErrAppender() send.Sender {
	s, _ := send.NewStreamLogger("", os.Stderr, send.LevelInfo{Default: level.Debug, Threshold: level.Debug})
	return s
}
21488
func StdIO(in io.Reader, out, err io.Writer) func(*Runner) error {
	return func(r *Runner) error {
		r.Stdin = in
		if out == nil {
			out = ioutil.Discard
		}
		r.Stdout = out
		if err == nil {
			err = ioutil.Discard
		}
		r.Stderr = err
		return nil
	}
}
186955
func (c *ExecCommand) Stdout() (io.WriteCloser, error) {
	if c.stdout == nil {
		if c.StdoutPath != "" {
			f, err := fifo.OpenWriter(c.StdoutPath)
			if err != nil {
				return nil, fmt.Errorf("failed to create stdout: %v", err)
			}
			c.stdout = f
		} else {
			c.stdout = nopCloser{ioutil.Discard}
		}
	}
	return c.stdout, nil
}
1011348
func (m *Model) SetStderr(err io.Writer) *Model {
	m.cmd.Stderr = err
	return m
}
1263058
func Stderr() *os.File {
	stderr := os.Stderr
	if panicwrap.Wrapped(nil) {
		stderr = wrappedStderr
	}

	return stderr
}
529510
func (cmd *CLI) StdOut() io.Writer {
	if cmd.stdOutput == nil {
		cmd.stdOutput = os.Stdout
	}
	return cmd.stdOutput
}
1187919
func (c *Subcommand) printError(err error) {
	if _, ok := err.(CommandLineError); ok {
		fmt.Fprintf(os.Stderr, "Bad command line: %s.\n\n", err)
		c.Flags.Usage()
	} else {
		os.Stderr.WriteString(strings.Join(CollectErrorMessages(err, nil), "\n"))
		os.Stderr.WriteString("\n")
	}
}
845029
func (c *Cmd) StderrPipe() (io.ReadCloser, error) {
	if c.Stderr != nil {
		return nil, errors.New("dexec: Stderr already set")
	}
	pr, pw := io.Pipe()
	c.Stderr = pw
	c.closeAfterWait = append(c.closeAfterWait, pw)
	return pr, nil
}
371796
func DupStderr() (*os.File, error) {
	proc, err := windows.GetCurrentProcess()
	if err != nil {
		return nil, err
	}

	var dupStderrFd windows.Handle
	err = windows.DuplicateHandle(
		proc, windows.Handle(os.Stderr.Fd()), proc, &dupStderrFd, 0,
		true, windows.DUPLICATE_SAME_ACCESS)
	if err != nil {
		return nil, err
	}

	stderrFile := os.NewFile(uintptr(dupStderrFd), "stderr")
	return stderrFile, nil
}
733700
func (c *Cursor) Err() error {
	if c == nil {
		return errNilCursor
	}

	c.mu.RLock()
	defer c.mu.RUnlock()

	return c.lastErr
}
1246979
func (parser *Parser) err() error {
	if parser.tokenError() {
		token := parser.nextToken()
		return fmt.Errorf("Tokenizer error: %s", token.String())
	}

	return nil
}