zsh-users
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: Chris Hansen <chris@phred.mine.nu>, zsh-users@sunsite.auc.dk
Subject: Re: coproc tutorial (Re: questions)
Date: Mon, 4 Oct 1999 06:22:09 +0000	[thread overview]
Message-ID: <991004062209.ZM952@candle.brasslantern.com> (raw)
In-Reply-To: <Pine.LNX.4.10.9910032146490.11619-100000@PHRED.dancris.com>

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

    http://www.zsh.org/cgi-bin/mla/redirect?USERNUMBER=1670

and good luck ...

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com


  reply	other threads:[~1999-10-04  6:42 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-03  8:30 questions Chris Hansen
1999-10-03 11:10 ` questions Stefan Berglund
1999-10-03 17:18   ` questions Bart Schaefer
1999-10-03 18:45   ` coproc tutorial (Re: questions) Bart Schaefer
1999-10-03 21:08     ` Chris Hansen
1999-10-04  2:01     ` coproc Chris Hansen
1999-10-04  4:41       ` coproc tutorial (Re: questions) Bart Schaefer
1999-10-04  5:21         ` Chris Hansen
1999-10-04  6:22           ` Bart Schaefer [this message]
1999-10-04 16:10 Jay Sekora
1999-10-04 18:42 ` Bart Schaefer
1999-10-11 10:45 Sven Wischnowsky
1999-10-11 12:55 ` Thomas Köhler
1999-10-12  6:53 Sven Wischnowsky
1999-10-12  8:42 ` Thomas Köhler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=991004062209.ZM952@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=chris@phred.mine.nu \
    --cc=zsh-users@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).