Skip to content

Support Win32 commands having nonstandard command line parsing rules #148

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

Merged
merged 3 commits into from
Jul 8, 2022

Conversation

nmisch
Copy link
Member

@nmisch nmisch commented Jul 6, 2021

This fixes a regression affecting Win32 batch files. The regression
originated in my #143. This implements the #143 (comment) design.

The introduction of IPC::Run::Win32Process makes Win32::Process::Create()
errors easier to reach, so I've included a commit to fix their reporting:

before: Bad file descriptor: Win32::Process::Create() at C:\...
after: The system cannot find the file specified.: Win32::Process::Create() at C:\...

b) Otherwise, use some amount of quoting sufficient for programs using
standard command line parsing rules and for Cygwin programs.

While this implementation handles Cygwin well for the tests in #143 (comment),
I found other cases that don't work. See the new comments in run.t. The
Cygwin situation is no worse than it was in the last IPC::Run release, and I
see no low-hanging fruit for improving it. I'm content with that.

nmisch added 3 commits July 6, 2021 04:35
Trivial examples worked, but my commit
fbd6d18 broke even those.  Cover all
known cases, subject to assumptions now described in documentation.  As
a surviving incompatibility compared to the last release, IPC::Run still
adds quotation marks to arguments where quotation marks are optional.
That is consequential in a batch file running "echo %*", for example.
One can argue that it's a good thing, but it is an incompatibility.

Discourage executing batch files with arguments, particularly when
argument values contain non-alphanumeric characters.  IPC::Run now
handles them well, but the batch file itself may not.
This unblocks general use of programs like cmd.exe and cscript.exe as
stages in IPC::Run pipelines.
Per its documentation, it reports via GetLastError(), not $!.
@wchristian
Copy link
Collaborator

That looks hella impressive and comprehensive. Do the tests also make #147 superfluous? Agreed on the cygwin bit.

@nmisch
Copy link
Member Author

nmisch commented Jul 8, 2021 via email

@wchristian
Copy link
Collaborator

Thanks for clarifying. That makes sense.

Fwiw, your changes seem to have fixed everything #147 gets at, so maybe it's best if @mohawk2 merges both. Happy to rebase if reordering is desired.

@nmisch
Copy link
Member Author

nmisch commented Oct 8, 2021

Folks with repository write access: is the matter of reviewing this pull request still in your queue? (#150 is another one ready to merge.)

@nmisch nmisch merged commit 26f687e into cpan-authors:master Jul 8, 2022
@nmisch
Copy link
Member Author

nmisch commented Jul 9, 2022

Upon merging this, run.t reached the 6h timeout instead of completing
(https://github.com/toddr/IPC-Run/runs/7246813528?check_suite_focus=true).
I've been unable to reproduce this, having tried six runs in GitHub Actions
and 4700 runs in a loop locally (Windows Server 2022). If you notice it
happening again, please let me know, especially if you see which line of the
script gets the stall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants