Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Bi-directional pipe



Hi,

Is there a way to make a bi-directional pipe in zsh?
That is, something like: foo | bar doing implicitly bar | foo, so
foo stdin <- bar stdout and
foo stdout <- bar stdin

Here is an example of what I want to do:

#!/bin/zsh

mkfifo fifo
exec 4>&1
(
exec 0<fifo
rm fifo
RES=0
while [ "$RES" -lt 10 ]; do
   echo "$RES+1"
   read RES
   echo "$RES" >&4
done
) | bc -q > fifo


The script enclosed between parenthesis writes and read to/from bc.
This approach uses a FIFO, so I would have hoped for a solution to
avoid needing a writable part of the filesystem ;-)

Maybe there is a magic incantation I can substitute to the | in order to
have a bi-directional pipe, or some function to create a pipe that I would
redirect to.

Thanks in advance for any help.

--
Guillaume



Messages sorted by: Reverse Date, Date, Thread, Author