evalEmpire / perl5i

A single module to fix as much of Perl 5 as possible in one go
http://search.cpan.org/perldoc?perl5i
Other
156 stars 42 forks source link

command_line_wrapper.t fails on windows due to IPC::System::Simple having pretty terrible logic #188

Open wchristian opened 13 years ago

wchristian commented 13 years ago

This test:

is capture { system @perl5icmd, "-e", "say 'Hello'" }, "Hello\n", "Hello perl5i!";

Generates this command-line call:

C:\Perl\bin\perl.exe -Mperl5i::cmd=perl5i.bat -Ilib, -e, say 'Hello' 

Which crashes the whole thing due to Fatal. (May want to add some eval or try to those tests.) This happens because IPC::System::Simple does this on windows:

my $pid = _spawn_or_die($command, "$command @args");

Which means it interpolates the args given into a string and separates them with commas.

In contrast, a core system call generates this kind of command line:

C:\Perl\bin\perl.exe -Mperl5i::cmd=perl5i.bat -Ilib -e "say 'Hello'"

This means that not only does IPC::System::Simple on windows completely butcher the arguments, it also makes us lose the platform-specific quoting.

schwern commented 13 years ago

On 2011.4.18 10:40 PM, wchristian wrote:

This test:

is capture { system @perl5icmd, "-e", "say 'Hello'" }, "Hello\n", "Hello perl5i!";

Generates this command-line call:

C:\Perl\bin\perl.exe -Mperl5i::cmd=perl5i.bat -Ilib, -e, say 'Hello' 

Which crashes the whole thing due to Fatal. (May want to add some eval or try to those tests.) This happens because IPC::System::Simple does this on windows:

my $pid = _spawn_or_die($command, "$command @args");

Which means it interpolates the args given into a string and separates them with commas.

Uhh... separates them with commas? How does that work?

In contrast, a core system call generates this kind of command line:

C:\Perl\bin\perl.exe -Mperl5i::cmd=perl5i.bat -Ilib -e "say 'Hello'"

This means that not only does IPC::System::Simple on windows completely butcher the arguments, it also makes us lose the platform-specific quoting.

Can IPC::System::Simple be fixed?

Being faith-based doesn't trump reality. -- Bruce Sterling

wchristian commented 13 years ago

Uhh... separates them with commas? How does that work?

Good question, it was a bit late last night, so it didn't occur to me that array interpolation in double-quoted strings doesn't work that way. Apparently $" is set to ',' at line 1074 in Fatal.pm:

local(\$", \$!) = (', ', 0);    # TODO - Why do we do this?

I guess preventing that could fix the issue of the commas. Still leaves the lack of system-specific quoting, but i don't think that's as important.

schwern commented 13 years ago

Back to the original question: is this something that can be fixed in IPC::System::Simple? pjf is definitely one of those folks that doesn't know much about Windows, I'm sure it's just an ignorant hack he'd be glad to have fixed.

wchristian commented 13 years ago

After some poking, yes, it's likely fixable. I've got the first four command line wrapper tests passing now. Sadly lack of quoting logic is making things hard and will take some more time. I think i may have a pull request for pjf in a few hours.