develooper Front page | perl.perl5.porters | Postings from October 2001

Re: [ID 20010929.014] Term::Complete screws up -ixon

Thread Previous | Thread Next
From:
Andy Dougherty
Date:
October 1, 2001 06:00
Subject:
Re: [ID 20010929.014] Term::Complete screws up -ixon
Message ID:
Pine.SOL.4.10.10110010834350.17326-100000@maxwell.phys.lafayette.edu
On Sun, 30 Sep 2001, Rafael Garcia-Suarez wrote:

> On 2001.09.30 01:07 Nicholas Clark wrote:
> > 
> > I'm not enough of a terminal wizard to know why the routines:
> > 	    $tty_raw_noecho = "$stty raw -echo";
> > 	    $tty_restore    = "$stty -raw echo";
> > 
> > don't do what they should, or whether a stty -all can be used instead to
> > capture terminal output and restore it perfectly (so sorry, no patch), but
> > I'd hope that something can be done to fix this irritating bug.
 
Here's the relevant section from the OpenBSD 2.9 stty(1) man page:

raw (-raw)  If set, change the modes of the terminal so that no input or
            output processing is performed.  If unset, change the modes
            of the terminal to some reasonable state that performs input
            and output processing.  Note that since the terminal driver
            no longer has a single RAW bit, it is not possible to intuit
            what flags were set prior to setting raw. This means that un-
            setting raw may not put back all the setting that were previ-
            ously in effect.  To set the terminal into a raw state and
            then accurately restore it, the following shell code is rec-
            ommended:

                  save_state=$(stty -g)
                  stty raw
                  ...
                  stty "$save_state"

> On Solaris and Linux, you can use `stty -g`. This outputs a string that can
> be given back as parameter to stty to restore the terminal state.
> But I don't know whether it's portable.

Alas, stty -g is not portable.  Stty stuff is notoriously non-portable.
BSD and SysV have traditionally been nearly completely different universes
when it comes to stty. Stty -g comes from the SysV end of the universe.  
Newer BSD-derived systems (such as all the various free *BSD systems)
probably have it, but older ones may well not. A further complication
(perhaps even with the above code) is that traditional BSD stty operated
on STDOUT, while SysV stty operates on STDIN.

I'd recommend only even attempting the Term::Complete test if stty -g is
successful. If it isn't successful, you can't be sure you can reset the
terminal state and hence you shouldn't mess it up.  Lastly, note that
older BSD-derived systems have traditionally been under-represented on
p5p, so tread carefully.

-- 
    Andy Dougherty		doughera@lafayette.edu
    Dept. of Physics
    Lafayette College, Easton PA 18042


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About