help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] coproc handling stderr


From: João Eiras
Subject: Re: [Help-bash] coproc handling stderr
Date: Tue, 3 Jan 2017 14:32:26 +0100

> So, the question is, coproc with stderr... how ? Worthy of a feature request ?

Or to make it simpler, if the posix pipe() was exposed in bash, the
use case would be mostly handled, since it creates an anonymous pipe,
like:

  #!/bin/bash

  # alias of pipe(PIPESSTDOUT) && pipe(PIPESSTDERR) ->
http://man7.org/linux/man-pages/man2/pipe.2.html
  makeanonpipe PIPESSTDOUT PIPESSTDERR

  background_task 1>${PIPESSTDOUT[0]} 2>${PIPESSTDERR[0]} &

  while blah; do
    read -r -t 0.05 ${PIPESSTDOUT[1]} line_out || read -r -t 0.05
${PIPESSTDERR[1]} line_err || ...
    # blah
  done

  exec ${PIPESSTDOUT[0]}<&- ${PIPESSTDERR[0]}<&-

The function could be something like
   makeanonpipe [NAMES...]
where there can be many names specified, defaulting to BASHPIPES is
nothing is specified (for instance). makeanonpipe is a bit of a
convoluted name, but just used as example here.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]