Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Bi-directional pipe
- X-seq: zsh-users 10357
- From: Guillaume Chazarain <guichaz@xxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Bi-directional pipe
- Date: Wed, 07 Jun 2006 14:50:42 +0200
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
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