-
Notifications
You must be signed in to change notification settings - Fork 571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pl2bat cannot read from stdin #16367
Comments
From martin@helios.deCreated by martin@helios.deThe "pl2bat" utility cannot read from standard input. Example: C:\> pl2bat < test.pl > test.bat The reason seems to be that pl2bat uses open() with 3 arguments. open( FILE, '<', $file ) or die "$0: Can't open which does not treat "-" as stdin. This used to work in earlier Perl releases, where the open() with 2 arguments is used. Using pl2bat with stdin/stdout is an important feature for our build workflow. Thank you for any help. Perl Info
|
From @jkeenanOn Thu, 18 Jan 2018 16:22:43 GMT, martin@helios.de wrote:
I believe you are correct. The code in question was applied as part of an enormous patch which converted most of the source code and documentation to 3-arg 'open'. The size of the patch made it difficult to review closely -- and the fact that we have (AFAICT) no specific tests for pl2bat in the core distribution test suite meant that we had no way of realizing our error. 1. Poster: Can you try out the patch attached? (I don't have Windows, so I cannot properly asses it.) 2. P5P: Is there any way we could include a test of pl2bat in the test suite? Thank you very much. -- |
From @jkeenan132736-pl2bat-0001-Revert-to-2-argument-open-so-as-to-permit-reading-fr.patchFrom 6a4e6837e3d6de1489718840157eeeaf0089d05e Mon Sep 17 00:00:00 2001
From: James E Keenan <jkeenan@cpan.org>
Date: Tue, 23 Jan 2018 11:37:31 -0500
Subject: [PATCH] Revert to 2-argument 'open' so as to permit reading from
STDIN.
In commit 1ae6ead94905dfee43773cf3b18949c91b33f9d1, applied to blead on Dec 23
2016, almost all instances in the source code and documentation which used
two-argument 'open' were switched to 3-arg 'open'. This had the unintended
side-effect of preventing 'pl2bat' being used with input from STDIN rather
than a file. Thanks to Martin Reinders for reporting this problem.
For: RT # 132736
---
win32/bin/pl2bat.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/win32/bin/pl2bat.pl b/win32/bin/pl2bat.pl
index 443f590..735fa0a 100644
--- a/win32/bin/pl2bat.pl
+++ b/win32/bin/pl2bat.pl
@@ -84,7 +84,7 @@ sub process {
my $line;
my $start= $Config{startperl};
$start= "#!perl" unless $start =~ /^#!.*perl/;
- open( FILE, '<', $file ) or die "$0: Can't open $file: $!";
+ open( FILE, $file ) or die "$0: Can't open $file: $!";
@file = <FILE>;
foreach $line ( @file ) {
$linenum++;
--
2.7.4
|
The RT System itself - Status changed from 'new' to 'open' |
From martin@helios.deOn 23.01.18 17:47, James E Keenan via RT wrote:
That does not yet work because _two_ open calls (the input file for reading and the output file for writing) were affected by 1ae6ead. The attached patch reverts both open calls to the previous version, and fixes the issue in my test. Regards, Martin |
From martin@helios.depl2bat.diffdiff --git a/win32/bin/pl2bat.pl b/win32/bin/pl2bat.pl
index 443f590..b30b16b 100644
--- a/win32/bin/pl2bat.pl
+++ b/win32/bin/pl2bat.pl
@@ -84,7 +84,7 @@ sub process {
my $line;
my $start= $Config{startperl};
$start= "#!perl" unless $start =~ /^#!.*perl/;
- open( FILE, '<', $file ) or die "$0: Can't open $file: $!";
+ open( FILE, $file ) or die "$0: Can't open $file: $!";
@file = <FILE>;
foreach $line ( @file ) {
$linenum++;
@@ -111,7 +111,7 @@ sub process {
close( FILE );
$file =~ s/$OPT{'s'}$//oi;
$file .= '.bat' unless $file =~ /\.bat$/i or $file =~ /^-$/;
- open( FILE, '>', $file ) or die "Can't open $file: $!";
+ open( FILE, ">$file" ) or die "Can't open $file: $!";
print FILE $myhead;
print FILE $start, ( $OPT{'w'} ? " -w" : "" ),
"\n#line ", ($headlines+1), "\n" unless $linedone;
|
Migrated from rt.perl.org#132736 (status was 'open')
Searchable as RT132736$
The text was updated successfully, but these errors were encountered: