David Korn writes:
 > cc: [EMAIL PROTECTED]
 > Subject: Re: [ast-users] How to redirect terminal stdin/stout to implement a 
 >  gdb-like "set inferior tty" in kshdb?
 > --------
 > 
 > > Recently I needed to debug a GNU autoconf configure script which seems
 > > to do funky things with stdin and stdout. I realized that the shell
 > > debuggers really should have the equivalent of gdb's "set inferior
 > > tty" (
 > > http://www.mcs.vuw.ac.nz/cgi-bin/info2www?(gdb)Input/Output)
 > I tried this url and I got the message
 >      Sorry! - Couldn't find target: "Input/Output)" in file "gdb".

Sorry, the outside parentheses were not indented to be part of the URL. So 
remove that final ")". Or to a google search for:
    gdb 'set inferior-tty'

 > > 
 > > The below is a little test that I came up with.
 > > 
 > > 
 > > #!/usr/local/bin/ksh
 > > 
 > > exec 7<&0 </dev/null 6>&1  # Line taken from an autoconf "configure" 
 > > script.
 > > #...
 > > typeset -i _Dbg_fdi
 > > exec {_Dbg_fdi} <>/dev/pts/1
 > > while read "foo >" args <&${_Dbg_fdi}
 > >  print -- "$line" >&${_Dbg_fdi}
 > > done
 > > 
 > > Unfortunately this doesn't work. I get the message:
 > > 
 > >  exec: {_Dbg_fdi}: not found
 > That is because you put a space between {_Dbg_fdi} and <>.  Just as a digit
 > must preceded the redirection operator without a space, the same is true
 > for {...}.

Ah, foiled again whether spaces must be/cannot be inserted. Thanks. 

 > > 
 > > Also, I'd like to test to see if a string name of a device is a valid
 > > terminal. Here's what I'm currently using:
 > > 
 > > 
 > > function _Dbg_is_tty {
 > >    (( $# != 1 )) && return 1
 > >    [[ -r "$1" && -w "$1" ]] && return 0
 > >    return 1
 > > }
 > Shouldn't [[ -t 1 ]] work?

If you mean -t $1 then, then my understanding is that -t uses file
descriptors; parameter $1 is the name of the device you want to
consider using as a tty.

If you mean -t 1 as in file descriptor 1, that works, but the name of
the device comes from the user. At this point I haven't tried issued a
redirect to open the name to get a descriptor yet. I could do that and
then make the test test, but then I have to make sure that file
descriptor (which might not be 1 because we're debugging a program and
the program might be using 1 itself) is moved around and that on error 
when I don't have a valid tty recovery keeps the old file descriptor.

 > > 
 > > One could also throw in a test for character devices. But is there
 > > something better?
 > > 
 > > Thanks.
 > 
 > David Korn
 > [EMAIL PROTECTED]
 > 
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users

Reply via email to