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



On Tue, Dec 9, 2008 at 7:12 AM, Stephane Chazelas
<Stephane_Chazelas@xxxxxxxx> 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" script.
> > #...
> > 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
> prompt or the echoed and controlling characters to fd 0, 1 or 2)
> but from/to a fd that was open to the attached terminal upon
> start and some that's some fd over 10 so probably hard to
> redirect (if I use strace here, I see it reads and writes to fd
> 11).

[later corrected "read" to "vared"].

Here the thing though. The debugger sometimes *does* read from a file
(the debugger "source"
command).

So in light of a program that does both - sometimes read from a file
and sometimes from a terminal,
any suggestions?

>
>
> You may want to consider the "clone" feature:
>
> info --index-search=clone zsh

clone seems intriguing, although right now I'm not sure what other
problems I'll get into.
A simple test with another tty gave:
   could not make /dev/pts/1 my controlling tty, job control disabled

Still for the case I was originally concerned with -- a
non-interactive script that becomes interactive -- it might work
better. Since the debugger wants to keep around a list of the input
and output file descriptors in use, would it make sense to use both
the exec <> and the clone? Or is there a way to capture the file
descriptor after the clone is done?


>
>
> >   builtin print -- "$line" >&${_Dbg_fdi}
>
> ITYM
> print -r -- "$line"

(So happens in the real code I *do* want shell escapes expanded ;-)
>
>
> >   line=''
> > done
> > echo "That's all folks! (${_Dbg_fdi})"
> >
> > Does zsh have <> like ksh does? It wasn't rejected, so I assume it does.
> [...]
>
> <> was Bourne already (though I beleive early versions had
> issues with it), so it should be recognised by every Bourne-like
> shell.
>
> --
> Stéphane



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