Skip Menu |
Report information
Id: 132736
Status: open
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: martin [at] helios.de
Cc:
AdminCc:

Operating System: (no value)
PatchStatus: (no value)
Severity: medium
Type: utilities
Perl Version: 5.26.1
Fixed In: (no value)



To: perlbug [...] perl.org
Date: Thu, 18 Jan 2018 17:13:18 +0100
From: Martin Reinders <martin [...] helios.de>
Subject: pl2bat cannot read from stdin
Download (untitled) / with headers
text/plain 4.3k
This is a bug report for perl from martin@helios.de, generated with the help of perlbug 1.40 running under perl 5.26.1. ----------------------------------------------------------------- [Please describe your issue here] The "pl2bat" utility cannot read from standard input. Example: C:\> pl2bat < test.pl > test.bat pl2bat.bat: Can't open -: No such file or directory at C:\Strawberry\perl\bin/pl2bat.bat line 101. The reason seems to be that pl2bat uses open() with 3 arguments. open( FILE, '<', $file ) or die "$0: Can't open $file: $!"; 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. Regards, Martin [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=utilities severity=medium --- Site configuration information for perl 5.26.1: Configured by strawberry-perl at Sun Sep 24 05:36:07 2017. Summary of my perl5 (revision 5 version 26 subversion 1) configuration: Platform: osname=MSWin32 osvers=6.3 archname=MSWin32-x64-multi-thread uname='Win32 strawberry-perl 5.26.1.1 #1 Sun Sep 24 05:32:33 2017 x64' config_args='undef' hint=recommended useposix=true d_sigaction=undef useithreads=define usemultiplicity=define use64bitint=define use64bitall=undef uselongdouble=undef usemymalloc=n default_inc_excludes_dot=define bincompat5005=undef Compiler: cc='gcc' ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing -mms-bitfields' optimize='-s -O2' cppflags='-DWIN32' ccversion='' gccversion='7.1.0' gccosandvers='' intsize=4 longsize=4 ptrsize=8 doublesize=8 byteorder=12345678 doublekind=3 d_longlong=define longlongsize=8 d_longdbl=define longdblsize=16 longdblkind=3 ivtype='long long' ivsize=8 nvtype='double' nvsize=8 Off_t='long long' lseeksize=8 alignbytes=8 prototype=define Linker and Libraries: ld='g++' ldflags ='-s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"' libpth=C:\STRAWB~1\c\lib C:\STRAWB~1\c\x86_64-w64-mingw32\lib C:\STRAWB~1\c\lib\gcc\x86_64-w64-mingw32\7.1.0 libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 libc= so=dll useshrplib=true libperl=libperl526.a gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs dlext=xs.dll d_dlsymun=undef ccdlflags=' ' cccdlflags=' ' lddlflags='-mdll -s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"' --- @INC for perl 5.26.1: C:/Strawberry/perl/site/lib C:/Strawberry/perl/vendor/lib C:/Strawberry/perl/lib --- Environment for perl 5.26.1: HOME (unset) LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=C:\ProgramData\Oracle\Java\javapath;c:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;Y:\bin;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\;C:\bin;C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules\TShell\TShell\;C:\Program Files\HELIOS.CD26\lib;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Tcl\bin;C:\Program Files\HELIOS.CD26\bin;C:\Program Files\HELIOS.CD26\sbin;C:\ProgramData\Oracle\Java\javapath;c:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;Y:\bin;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools\;C:\bin;C:\Windows\SysWOW64\WindowsPowerShell\v1.0\Modules\TShell\TShell\;C:\Program Files\HELIOS.CD26\lib;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin PERL_BADLANG (unset) SHELL=CMD.EXE
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.4k
On Thu, 18 Jan 2018 16:22:43 GMT, martin@helios.de wrote: Show quoted text
> > This is a bug report for perl from martin@helios.de, > generated with the help of perlbug 1.40 running under perl 5.26.1. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > The "pl2bat" utility cannot read from standard input. Example: > > C:\> pl2bat < test.pl > test.bat > pl2bat.bat: Can't open -: No such file or directory at > C:\Strawberry\perl\bin/pl2bat.bat line 101. > > The reason seems to be that pl2bat uses open() with 3 arguments. > > open( FILE, '<', $file ) or die "$0: Can't open $file: $!"; > > 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. > Regards, Martin > >
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. -- James E Keenan (jkeenan@cpan.org)
Subject: 132736-pl2bat-0001-Revert-to-2-argument-open-so-as-to-permit-reading-fr.patch
From 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
Subject: Re: [perl #132736] pl2bat cannot read from stdin
From: Martin Reinders <martin [...] helios.de>
Date: Wed, 24 Jan 2018 10:13:09 +0100
To: perlbug-followup [...] perl.org
Download (untitled) / with headers
text/plain 941b
On 23.01.18 17:47, James E Keenan via RT wrote: Show quoted text
> > 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. >
That does not yet work because _two_ open calls (the input file for reading and the output file for writing) were affected by 1ae6ead94905dfee43773cf3b18949c91b33f9d1. The attached patch reverts both open calls to the previous version, and fixes the issue in my test. Regards, Martin
Download pl2bat.diff
text/plain 875b

Message body is not shown because sender requested not to inline it.



This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org