summaryrefslogtreecommitdiff
path: root/lib/Term
diff options
context:
space:
mode:
authorJonathan Stowe <gellyfish@gellyfish.com>2006-03-13 16:09:44 +0000
committerSteve Hay <SteveHay@planit.com>2006-03-28 10:38:52 +0000
commit3b2be7b35137c72736bf3f9305f26b39b783dd74 (patch)
treea99353986be5c3bd333724bf9474ecfcf9316d3b /lib/Term
parent988c775cbb77355593cf99dafc219bbd3d6a62d5 (diff)
downloadperl-3b2be7b35137c72736bf3f9305f26b39b783dd74.tar.gz
Re: [cpan #17773] Bug in Term::ReadKey being trigger by a bug in Term::ReadLine
Message-Id: <1142266184.5811.141.camel@orpheus.gellyfish.com> p4raw-id: //depot/perl@27619
Diffstat (limited to 'lib/Term')
-rw-r--r--lib/Term/ReadLine.pm17
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/Term/ReadLine.pm b/lib/Term/ReadLine.pm
index 48eb9911a6..0b25379b36 100644
--- a/lib/Term/ReadLine.pm
+++ b/lib/Term/ReadLine.pm
@@ -209,13 +209,15 @@ sub addhistory {}
sub findConsole {
my $console;
+ my $consoleOUT;
if ($^O eq 'MacOS') {
$console = "Dev:Console";
} elsif (-e "/dev/tty") {
$console = "/dev/tty";
} elsif (-e "con" or $^O eq 'MSWin32') {
- $console = "con";
+ $console = 'CONIN$';
+ $consoleOUT = 'CONOUT$';
} else {
$console = "sys\$command";
}
@@ -231,10 +233,10 @@ sub findConsole {
}
}
- my $consoleOUT = $console;
+ $consoleOUT = $console unless defined $consoleOUT;
$console = "&STDIN" unless defined $console;
if (!defined $consoleOUT) {
- $consoleOUT = defined fileno(STDERR) ? "&STDERR" : "&STDOUT";
+ $consoleOUT = defined fileno(STDERR) && $^O ne 'MSWin32' ? "&STDERR" : "&STDOUT";
}
($console,$consoleOUT);
}
@@ -247,8 +249,13 @@ sub new {
if (@_==2) {
my($console, $consoleOUT) = $_[0]->findConsole;
- open(FIN, "<$console");
- open(FOUT,">$consoleOUT");
+
+ # the Windows CONIN$ needs GENERIC_WRITE mode to allow
+ # a SetConsoleMode() if we end up using Term::ReadKey
+ open FIN, ( $^O eq 'MSWin32' && $console eq 'CONIN$' ) ? "+<$console" :
+ "<$console";
+ open FOUT,">$consoleOUT";
+
#OUT->autoflush(1); # Conflicts with debugger?
my $sel = select(FOUT);
$| = 1; # for DB::OUT