Skip to content

[MNG-8650] Fix MAVEN_ARGS backslash stripping on Windows#12349

Open
gnodet wants to merge 1 commit into
maven-4.0.xfrom
fix-11487-4.0.x
Open

[MNG-8650] Fix MAVEN_ARGS backslash stripping on Windows#12349
gnodet wants to merge 1 commit into
maven-4.0.xfrom
fix-11487-4.0.x

Conversation

@gnodet

@gnodet gnodet commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Backport of #12348 to maven-4.0.x.

Fixes #11487

Summary

  • Move $MAVEN_ARGS out of the eval'd cmd string in the mvn launcher script
  • The variable reference is now single-quoted ('$MAVEN_ARGS') on the eval line, so eval expands it as a normal variable rather than re-parsing the already-expanded value — preserving backslashes
  • Same approach used for "$@" in PR Fix mvn script expanding ${...} in CLI arguments #11983

Root cause

eval exec "$cmd" re-parses the expanded string. When $MAVEN_ARGS was embedded in cmd at assignment time, its value became literal text in the eval'd string, causing backslashes (e.g. Windows paths like C:\Users\...) to be interpreted as escape characters and stripped.

Test plan

  • Set MAVEN_ARGS="-Dfoo=C:\path\to\file" and verify the property value reaches Maven with backslashes intact
  • Verify MAVEN_OPTS with quoted values still works correctly (eval still handles those)
  • Verify MAVEN_ARGS with multiple space-separated arguments still works

🤖 Generated with Claude Code

Move $MAVEN_ARGS out of the eval'd cmd string so that eval
does not re-parse its value and strip backslashes.  The variable
reference is now single-quoted ('$MAVEN_ARGS') on the eval line,
matching the existing treatment of "$@" from PR #11983.

Closes #11487

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gnodet gnodet added this to the 4.0.0-rc-6 milestone Jun 23, 2026
@gnodet gnodet added bug Something isn't working backport labels Jun 23, 2026
@gnodet gnodet requested review from cstamas and mthmulders June 23, 2026 10:31
@gnodet gnodet added the mvn40 label Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working mvn40

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant