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

Re: Is this correct? Redirecting stdin/stout to implement a gdb-like "set inferior tty" in zshdb



Stephane Chazelas wrote:
> On Tue, Dec 09, 2008 at 12:12:13PM +0000, Stephane Chazelas wrote:
> > On Tue, Dec 09, 2008 at 06:27:48AM -0500, Rocky Bernstein wrote:
> > [...]
> > > exec 7<&0 </dev/null 6>&1  # Line taken from an autoconf "configure" scri
> pt.
> > > #...
> > > exec {_Dbg_fdi} <> $1
> > > while : ; do
> > >   vared -e -h -p "foo> " line <&${_Dbg_fdi} || break
> > 
> > The thing is read doesn't read from fd 0 (not does it write its
> [...]          ^^^^
> 
> Sorry, I meant "vared" above.

Ah, yes, I missed that, which is the key point.  If vared doesn't yet
have a terminal (because it's a non-interactive shell, as here), it will
open /dev/tty, which isn't what you want (but worked in my test).

It would be relatively straightforward to supply vared with an option to
use as the terminal if there was none.  However it would be messier to
have it use the given terminal to replace any existing terminal in an
interactive shell (it *might* work saving and restoring the FDs but it's
a little fraught since zle not's designed to manage multiple terminals
at once), so that option would probably be limited to use in
non-interactive shells.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070



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