@@ -75,6 +75,8 @@ history. Returns the old value.
7575returns an array with two strings that give most appropriate names for
7676files for input and output using conventions C<"E<lt> $in">, C<"E<gt> out">.
7777
78+ The strings returned may not be useful for 3-argument open().
79+
7880=item Attribs
7981
8082returns a reference to a hash which describes internal configuration
@@ -229,12 +231,17 @@ sub readline {
229231}
230232sub addhistory {}
231233
234+ # used for testing purpose
235+ sub devtty { return ' /dev/tty' }
236+
232237sub findConsole {
233238 my $console ;
234239 my $consoleOUT ;
235240
236- if ($^O ne ' MSWin32' and -e " /dev/tty" ) {
237- $console = " /dev/tty" ;
241+ my $devtty = devtty();
242+
243+ if ($^O ne ' MSWin32' and -e $devtty ) {
244+ $console = $devtty ;
238245 } elsif ($^O eq ' MSWin32' or $^O eq ' msys' or -e " con" ) {
239246 $console = ' CONIN$' ;
240247 $consoleOUT = ' CONOUT$' ;
@@ -248,7 +255,7 @@ sub findConsole {
248255
249256 $consoleOUT = $console unless defined $consoleOUT ;
250257 $console = " &STDIN" unless defined $console ;
251- if ($console eq " /dev/tty " && !open (my $fh , " <" , $console )) {
258+ if ($console eq $devtty && !open (my $fh , " <" , $console )) {
252259 $console = " &STDIN" ;
253260 undef ($consoleOUT );
254261 }
@@ -266,11 +273,10 @@ sub new {
266273 if (@_ ==2) {
267274 my ($console , $consoleOUT ) = $_ [0]-> findConsole;
268275
269-
270276 # the Windows CONIN$ needs GENERIC_WRITE mode to allow
271277 # a SetConsoleMode() if we end up using Term::ReadKey
272- open FIN, ( $^O eq ' MSWin32' && $console eq ' CONIN$' ) ? " +< $console " :
273- " < $console " ;
278+ open FIN, (( $^O eq ' MSWin32' && $console eq ' CONIN$' ) ? ' +< ' : ' < ' ), $console ;
279+ # RT #132008: Still need 2-arg open here
274280 open FOUT," >$consoleOUT " ;
275281
276282 # OUT->autoflush(1); # Conflicts with debugger?
@@ -320,7 +326,7 @@ sub Features { \%features }
320326
321327package Term::ReadLine ; # So late to allow the above code be defined?
322328
323- our $VERSION = ' 1.15 ' ;
329+ our $VERSION = ' 1.17 ' ;
324330
325331my ($which ) = exists $ENV {PERL_RL } ? split /\s +/, $ENV {PERL_RL } : undef ;
326332if ($which ) {
0 commit comments