Revert usage of cmd on Windows - #109
Conversation
965bed7 to
6168f2b
Compare
6168f2b to
5f9a5ec
Compare
|
Note: GitHub action verify problem with Java 16-ea is not part of this PR. |
|
(@michael-o: Requested changes have been done) |
See #116 |
|
Is this PR (or #110) not relevant 😢 ? |
5b90f41 to
5c05119
Compare
|
@slachiewicz Rebase this PR after closing #110 |
5c05119 to
436fb68
Compare
There was a problem hiding this comment.
Pull request overview
This PR removes the implicit Windows cmd.exe wrapping behavior from Commandline execution/commandline generation, shifting responsibility for invoking built-ins (echo, dir, .cmd/.bat) to the caller. It also updates unit tests to reflect the new Windows behavior.
Changes:
- Deprecates
Commandline#getCommandline()and makes it return the raw (non-shell) command line on all OSes. - Updates
Commandline#execute()to execute the raw command line (no implicit Windows shell wrapping). - Adjusts
CommandlineTestcases that previously depended on Windows shell built-ins.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/main/java/org/codehaus/plexus/util/cli/Commandline.java | Removes Windows-specific shell wrapping from getCommandline() and aligns execution toward raw command arrays. |
| src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java | Updates tests to explicitly invoke cmd for Windows built-ins/scripts. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| String binary = "mvn"; | ||
| if (Os.isFamily(Os.FAMILY_WINDOWS)) { | ||
| binary += ".cmd"; | ||
| } |
| if (Os.isFamily(Os.FAMILY_WINDOWS)) { | ||
| cmd.createArg().setValue("Hello"); | ||
| executable = "cmd"; | ||
| cmd.createArg().setValue("/X"); | ||
| cmd.createArg().setValue("/C"); | ||
| cmd.createArg().setValue("echo"); | ||
| } |
| if (workingDir == null) { | ||
| process = Runtime.getRuntime().exec(getCommandline(), environment, workingDir); | ||
| process = Runtime.getRuntime().exec(getRawCommandline(), environment, workingDir); | ||
| } else { |
This PR is an update of old previous staling PR #41
cf. #17 (comments from May 2018): Revert the usage of
cmd.exe(on Windows), because prevents the destroy/kill launched by this way whenCTRL+C.For history: This Windows shell specific is removed since plexus-utils 3.0.15, except for 3.1.0.
On Windows, the usage of cmd builtin (like
echo) or.cmd/.baton PATH should be implemented by the client/user.Another approach could be a dedicated option: See #110