From: Martti Rahkila Date: Sat, 18 Jan 2003 00:25:39 +0000 (+0200) Subject: Term::Complete problem + fix (Was: Re: muttprofile + perl 5.8) X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e05a8f29fa78aef20a9869bf742d9b3217cda019;p=p5sagit%2Fp5-mst-13.2.git Term::Complete problem + fix (Was: Re: muttprofile + perl 5.8) Message-ID: <20030118002539.A30585@wurlitzer.hut.fi> (chose the 'even safer' version) p4raw-id: //depot/perl@18553 --- diff --git a/lib/Term/Complete.pm b/lib/Term/Complete.pm index 4ae4541..c74907b 100644 --- a/lib/Term/Complete.pm +++ b/lib/Term/Complete.pm @@ -5,7 +5,7 @@ require Exporter; use strict; our @ISA = qw(Exporter); our @EXPORT = qw(Complete); -our $VERSION = '1.4'; +our $VERSION = '1.401'; # @(#)complete.pl,v1.2 (me@anywhere.EBay.Sun.COM) 09/23/91 @@ -66,7 +66,7 @@ Wayne Thompson =cut -our($complete, $kill, $erase1, $erase2, $tty_raw_noecho, $tty_restore, $stty); +our($complete, $kill, $erase1, $erase2, $tty_raw_noecho, $tty_restore, $stty, $tty_safe_restore); our($tty_saved_state) = ''; CONFIG: { $complete = "\004"; @@ -77,6 +77,7 @@ CONFIG: { if (-x $s) { $tty_raw_noecho = "$s raw -echo"; $tty_restore = "$s -raw echo"; + $tty_safe_restore = $tty_restore; $stty = $s; last; } @@ -106,8 +107,8 @@ sub Complete { $tty_saved_state = undef; } else { - chomp $tty_saved_state; - $tty_restore = qq($stty "$tty_saved_state"); + $tty_saved_state =~ s/\s+$//g; + $tty_restore = qq($stty "$tty_saved_state" 2>/dev/null); } } system $tty_raw_noecho if defined $tty_raw_noecho; @@ -169,10 +170,18 @@ sub Complete { } } } - system $tty_restore if defined $tty_restore; + + # system $tty_restore if defined $tty_restore; + if (defined $tty_saved_state && defined $tty_restore && defined $tty_safe_restore) + { + system $tty_restore; + if ($?) { + # tty_restore caused error + system $tty_safe_restore; + } + } print("\n"); $return; } 1; -