co-processes and bash (ksh does it, can bash?)

co-processes and bash (ksh does it, can bash?)

Post by Larry Williams » Thu, 27 Jun 1991 23:32:54



Ksh supports the concept of a co-process. You can start a process in
the background with it's stdin and stdout connected to the shell. You
do this by putting the |& operator after the command. You can then use
read -p to read from the co-process and print -p to write to it.

I don't see any mention of this nice feature in the BASH
documentation.

Is there any plan to support this in the future?

Is there some other, more general procedure, by which this same
feature could be accomplished?

-Larry

 
 
 

co-processes and bash (ksh does it, can bash?)

Post by Paul Falst » Fri, 28 Jun 1991 16:10:42



>Ksh supports the concept of a co-process. You can start a process in
>the background with it's stdin and stdout connected to the shell. You
>do this by putting the |& operator after the command. You can then use
>read -p to read from the co-process and print -p to write to it.

>I don't see any mention of this nice feature in the BASH
>documentation.

Hmm.  zsh supports this, using a slightly different syntax.  You
use the "coproc" keyword instead of |&, and use >&p or <&p instead
of -p.  I'd probably use process substitution instead, though, to
open a pipe to or from a process.  The coproc stuff wasn't tested very
well because I couldn't really think of a good use for it.

--
Paul Falstad                     | 10 PRINT "PRINCETON CS"