Skip to content

Revert usage of cmd on Windows - #109

Open
axel3rd wants to merge 1 commit into
codehaus-plexus:masterfrom
axel3rd:update-41-Revert_usage_of_cmd_on_Windows
Open

Revert usage of cmd on Windows#109
axel3rd wants to merge 1 commit into
codehaus-plexus:masterfrom
axel3rd:update-41-Revert_usage_of_cmd_on_Windows

Conversation

@axel3rd

@axel3rd axel3rd commented Dec 21, 2020

Copy link
Copy Markdown
Contributor

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 when CTRL+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 / .bat on PATH should be implemented by the client/user.


Another approach could be a dedicated option: See #110

@axel3rd
axel3rd marked this pull request as draft December 21, 2020 11:30
@axel3rd
axel3rd force-pushed the update-41-Revert_usage_of_cmd_on_Windows branch from 965bed7 to 6168f2b Compare December 21, 2020 11:32
Comment thread src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java Outdated
Comment thread src/test/java/org/codehaus/plexus/util/cli/CommandlineTest.java Outdated
@axel3rd
axel3rd force-pushed the update-41-Revert_usage_of_cmd_on_Windows branch from 6168f2b to 5f9a5ec Compare December 21, 2020 13:05
@axel3rd
axel3rd marked this pull request as ready for review December 21, 2020 13:25
@axel3rd

axel3rd commented Dec 21, 2020

Copy link
Copy Markdown
Contributor Author

Note: GitHub action verify problem with Java 16-ea is not part of this PR.

@axel3rd
axel3rd requested a review from michael-o January 4, 2021 11:48
@axel3rd

axel3rd commented Jan 4, 2021

Copy link
Copy Markdown
Contributor Author

(@michael-o: Requested changes have been done)

@axel3rd

axel3rd commented Jan 4, 2021

Copy link
Copy Markdown
Contributor Author

Note: GitHub action verify problem with Java 16-ea is not part of this PR.

See #116

@axel3rd

axel3rd commented Feb 26, 2021

Copy link
Copy Markdown
Contributor Author

Is this PR (or #110) not relevant 😢 ?

@michael-o
michael-o removed their request for review October 23, 2022 08:59
@slachiewicz
slachiewicz marked this pull request as draft January 5, 2025 10:44
@slachiewicz slachiewicz added need-rebase Branch has conflicts and needs a rebase before it can merge enhancement New feature or request labels Aug 16, 2026
@axel3rd
axel3rd force-pushed the update-41-Revert_usage_of_cmd_on_Windows branch 2 times, most recently from 5b90f41 to 5c05119 Compare August 16, 2026 21:36
@axel3rd
axel3rd marked this pull request as ready for review August 16, 2026 21:39
@axel3rd
axel3rd requested a review from michael-o August 16, 2026 21:39
@axel3rd

axel3rd commented Aug 16, 2026

Copy link
Copy Markdown
Contributor Author

@slachiewicz Rebase this PR after closing #110

Comment thread src/main/java/org/codehaus/plexus/util/cli/Commandline.java Outdated
@slachiewicz slachiewicz removed the need-rebase Branch has conflicts and needs a rebase before it can merge label Aug 17, 2026
@axel3rd
axel3rd force-pushed the update-41-Revert_usage_of_cmd_on_Windows branch from 5c05119 to 436fb68 Compare August 17, 2026 21:10
@axel3rd
axel3rd requested a review from michael-o August 17, 2026 21:13

@michael-o michael-o left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@slachiewicz WDYT?

@slachiewicz
slachiewicz requested a lite review from Copilot August 18, 2026 11:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 CommandlineTest cases 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.

Comment on lines +81 to +84
String binary = "mvn";
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
binary += ".cmd";
}
Comment on lines +104 to +110
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
cmd.createArg().setValue("Hello");
executable = "cmd";
cmd.createArg().setValue("/X");
cmd.createArg().setValue("/C");
cmd.createArg().setValue("echo");
}
Comment on lines 583 to 585
if (workingDir == null) {
process = Runtime.getRuntime().exec(getCommandline(), environment, workingDir);
process = Runtime.getRuntime().exec(getRawCommandline(), environment, workingDir);
} else {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants