Closed andrewgregory closed 7 years ago
Could you live with this:
$^O eq "MSWin32" and $xls = qq{"$xls"};
exec { "xlscat" } "xlscat", "-c", @ARGV, $xls;
I really dislike the "do" workaround. I tested the above
We're working around some pretty ridiculous Windows behavior here, so I can live with whatever you want to do. That does still leave the issue that the main process exits while xlscat is still working, but that's a minor annoyance relative to not being able to handle whitespace.
Unless you're considering merging this to fix the early termination issue, 4a5ffe31e14b8483b6f2f344e8afe609e545489d obsoletes this PR.
Due to how Windows passes arguments to programs, dealing with arguments with whitespace is tricky and perl's exec function does not do it correctly. Any arguments with whitespace get split by the exec'd process. The exec'd process also appears to fork causing the command prompt to reappear only to immediately be covered in error output from xlscat due to the bad arguments.
Fortunately, since xlscat is just another perl script, we can run it directly in the existing perl process.
Some references on Windows argument passing: https://blogs.msdn.microsoft.com/twistylittlepassagesallalike/2011/04/23/everyone-quotes-command-line-arguments-the-wrong-way/ http://blogs.perl.org/users/graham_knop/2011/12/using-system-or-exec-safely-on-windows.html