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

Re: PATCH: more selection



Peter Stephenson wrote:
> The following patch adds an fd-watching facility to zle.  You tell zle
> (via zle -F) to select on an fd and give it a function handler.  When data
> is available for reading on that handle (only reading, at the moment),
> the handler will be called, and zle will sail on without returning.
> This allows you to handle input from other sources while the shell is
> inactive waiting for terminal input.  It's all handled synchronously
> within zle, so it should be free of the hazards of asynchronous input.

This has been working smoothly for me for several days with multiple TCP
connections, so I've committed it, with small tweaks.  The chance of
fallout if you are not using the new feature is pretty small.

I've been putting together a function script that uses this to make a
front-end to remote connections, vaguely expect-like but with much
better interactive features.  It was designed so I can do on UNIX
remotely from a single existing zsh session what I used to have to do
with a set of completely different command line tools running under
Windows, but it is entirely general purpose; you could write a `talk'
tool integrated into zsh, for example.  It combines the use of ztcp,
zselect and zle -F.  I may or may not tidy it up and post it.

(A scan of the code shows it doesn't rely on fd multiplexing with zselect,
only with zle -F, so that part could be done without the module if we
implemented the bash version of `read -t <timeout>'.  It's annoying I
picked that letter for polling.)

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 392070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************



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