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

Re: coproc tutorial (Re: questions)




On Mon, 4 Oct 1999, Bart Schaefer wrote:

> On Oct 3,  2:08pm, Chris Hansen wrote:
> } Subject: Re: coproc tutorial (Re: questions)
> }
> } I now understan how to coproc, when is it actually the best way?

<<SNIP>>

> }
> } Is there a way to write to the keyboard of a coprocess?
> } If not, how hard would this feature be to add?
> 
> I can't answer that, as I'm completely mystified as to what "the keyboard
> of a coprocess" means.  A coprocess is a background job; to the extent
> that it has "a keyboard" it would be the same one as the shell that had
> started it.  Can you give an example of what you're trying to accomplish?
> 

Every tty/pty has a keyboard.  I don't know if that is true of
coprocesses/background processes.  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.

I can echo, print and pipe to stdin on the coproc, I can pipe to the
screen of the next terminal, but I'm beginning to suspect it can't be
done. (which is what you told me in the first place)

The code looked something like this:

#!/bin/zsh -i

coproc /usr/bin/nslookup

while true; do
	TEST=">"
	NSLOUT=" "
	while [[ $TEST != $NSLOUT ]] ; do
		print -n $NSLOUT
		read -pk NSLOUT
	done
	read 'QUERY?>'
	print -p $QUERY
done


Thanks
Chris




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