Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 4466588

Browse files
committed
Term-ReadLine-1.17
1 parent 07deb4a commit 4466588

File tree

6 files changed

+69
-8
lines changed

6 files changed

+69
-8
lines changed

MANIFEST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3873,6 +3873,7 @@ dist/Term-Complete/t/Complete.t See if Term::Complete works
38733873
dist/Term-ReadLine/lib/Term/ReadLine.pm Stub readline library
38743874
dist/Term-ReadLine/t/AE.t See if Term::ReadLine works
38753875
dist/Term-ReadLine/t/AETk.t See if Term::ReadLine works
3876+
dist/Term-ReadLine/t/ReadLine-STDERR.t
38763877
dist/Term-ReadLine/t/ReadLine.t See if Term::ReadLine works
38773878
dist/Term-ReadLine/t/Tk.t See if Term::ReadLine works
38783879
dist/Test/lib/Test.pm A simple framework for writing test scripts

Porting/Maintainers.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,7 @@ package Maintainers;
13021302
},
13031303

13041304
'Term::ReadLine' => {
1305-
'DISTRIBUTION' => 'FLORA/Term-ReadLine-1.14.tar.gz',
1305+
'DISTRIBUTION' => 'FLORA/Term-ReadLine-1.17.tar.gz',
13061306
'FILES' => q[dist/Term-ReadLine],
13071307
'EXCLUDED' => [qr{^t/release-.*\.t}],
13081308
},

dist/Module-CoreList/lib/Module/CoreList.pm

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17570,6 +17570,7 @@ our %delta = (
1757017570
'Scalar::Util' => '1.50_11',
1757117571
'Sub::Util' => '1.50_11',
1757217572
'Socket' => '2.027_04',
17573+
'Term::ReadLine' => '1.17',
1757317574
'XSLoader' => '1.04c',
1757417575
},
1757517576
removed => {

dist/Term-ReadLine/lib/Term/ReadLine.pm

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ history. Returns the old value.
7575
returns an array with two strings that give most appropriate names for
7676
files 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
8082
returns a reference to a hash which describes internal configuration
@@ -229,12 +231,17 @@ sub readline {
229231
}
230232
sub addhistory {}
231233

234+
# used for testing purpose
235+
sub devtty { return '/dev/tty' }
236+
232237
sub 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

321327
package Term::ReadLine; # So late to allow the above code be defined?
322328

323-
our $VERSION = '1.15';
329+
our $VERSION = '1.17';
324330

325331
my ($which) = exists $ENV{PERL_RL} ? split /\s+/, $ENV{PERL_RL} : undef;
326332
if ($which) {
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!./perl -w
2+
use strict;
3+
4+
use Test::More;
5+
6+
## unit test for RT 132008 - https://rt.perl.org/Ticket/Display.html?id=132008
7+
8+
if ( $^O eq 'MSWin32' || !-e q{/dev/tty} ) {
9+
plan skip_all => "Not tested on windows or when /dev/tty does not exist";
10+
}
11+
else {
12+
plan tests => 9;
13+
}
14+
15+
if ( -e q[&STDERR] ) {
16+
note q[Removing existing file &STDERR];
17+
unlink q[&STDERR] or die q{Cannot remove existing file &STDERR [probably created from a previous run]};
18+
}
19+
20+
use_ok('Term::ReadLine');
21+
can_ok( 'Term::ReadLine::Stub', qw{new devtty findConsole} );
22+
is( Term::ReadLine->devtty(), q{/dev/tty}, "check sub devtty" );
23+
SKIP:
24+
{
25+
open my $tty, "<", Term::ReadLine->devtty()
26+
or skip "Cannot open tty", 1;
27+
-t $tty
28+
or skip "No tty found, so findConsole() won't return /dev/tty", 1;
29+
my @out = Term::ReadLine::Stub::findConsole();
30+
is_deeply \@out, [ q{/dev/tty}, q{/dev/tty} ], "findConsole is using /dev/tty";
31+
}
32+
33+
{
34+
no warnings 'redefine';
35+
my $donotexist = q[/this/should/not/exist/hopefully];
36+
37+
ok !-e $donotexist, "File $donotexist does not exist";
38+
# double mention to prevent warning
39+
local *Term::ReadLine::Stub::devtty =
40+
*Term::ReadLine::Stub::devtty = sub { $donotexist };
41+
is( Term::ReadLine->devtty(), $donotexist, "devtty mocked" );
42+
43+
my @out = Term::ReadLine::Stub::findConsole();
44+
is_deeply \@out, [ q{&STDIN}, q{&STDERR} ], "findConsole isn't using /dev/tty" or diag explain \@out;
45+
46+
ok !-e q[&STDERR], 'file &STDERR do not exist before Term::ReadLine call';
47+
my $tr = Term::ReadLine->new('whatever');
48+
ok !-e q[&STDERR], 'file &STDERR was not created by mistake';
49+
}

pod/perlcdelta.pod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,10 @@ Fixup the new pairmap spill code.
468468

469469
=item L<Socket> 2.027_04
470470

471+
=item L<Term::ReadLine> 1.17
472+
473+
fix for empty &STDERR files, RT #132008
474+
471475
=item L<XSLoader> 1.04c
472476

473477
Fix wrong usage of C<SvREFCNT_inc_simple_NN> with a function, fixes a memory leak.

0 commit comments

Comments
 (0)