Zsh Mailing List Archive
Messages sorted by:
Re: coproc tutorial (Re: questions)
- X-seq: zsh-users 2656
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: Chris Hansen <chris@xxxxxxxxxxxxx>, zsh-users@xxxxxxxxxxxxxx
- Subject: Re: coproc tutorial (Re: questions)
- Date: Mon, 4 Oct 1999 06:22:09 +0000
- In-reply-to: <Pine.LNX.4.10.9910032146490.11619-100000@xxxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
- References: <Pine.LNX.4.10.9910032146490.11619-100000@xxxxxxxxxxxxxxxxx>
On Oct 3, 10:21pm, Chris Hansen wrote:
} Subject: Re: coproc tutorial (Re: questions)
} What I was trying to do was write a script that would allow me to use
} all of zsh's command line magic inside of other programs. I had some
} nice results with bc, because it will take things from standard in.
} I didn't do near as well with nslookup because it insists on taking
} commands from the keyboard.
Aha. Well, when I tried your script here, the problem with it was not
nslookup reading from the keyboard; it was good old output buffering,
just as I originally warned about ... nslookup gets the first query
that your script sends it and computes the answer; but because standard
*output* is not a terminal, it doesn't flush its buffer, and "read -pk"
hangs the next time around your loop.
This is typical stdio-library behavior: Output is block-buffered in
1024-byte (or 4096-byte or 8192-byte) chunks when the output is to a
pipe or file, and line-buffered or unbuffered when to a terminal. By
putting nslookup in the coprocess, you put it into block-buffered mode.
You can avoid this by getting yourself a little program that opens a
pty and runs nslookup there; "expect" can do it, and there are several
others whose names I've forgotten.
But in any case you need to do a lot more than just call "read" to get
zsh's editor involved in all of this. See
and good luck ...
Bart Schaefer Brass Lantern Enterprises
Messages sorted by: