You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/06/23 07:31:14 UTC

(maven) 01/01: [MNG-8650] Fix MAVEN_ARGS backslash stripping on Windows

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch fix-11487
in repository https://gitbox.apache.org/repos/asf/maven.git

commit f4ca2c8a5d11cd064b6858f3732d6b37e30c6df0
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Tue Jun 23 07:31:01 2026 +0000

    [MNG-8650] Fix MAVEN_ARGS backslash stripping on Windows
    
    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 <no...@anthropic.com>
---
 apache-maven/src/assembly/maven/bin/mvn | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/apache-maven/src/assembly/maven/bin/mvn b/apache-maven/src/assembly/maven/bin/mvn
index 04b149010b..85a9a98805 100755
--- a/apache-maven/src/assembly/maven/bin/mvn
+++ b/apache-maven/src/assembly/maven/bin/mvn
@@ -286,15 +286,14 @@ cmd="\"$JAVACMD\" \
   \"-Dmaven.mainClass=$MAVEN_MAIN_CLASS\" \
   \"-Dlibrary.jline.path=${MAVEN_HOME}/lib/jline-native\" \
   \"-Dmaven.multiModuleProjectDirectory=$MAVEN_PROJECTBASEDIR\" \
-  $LAUNCHER_CLASS \
-  $MAVEN_ARGS"
+  $LAUNCHER_CLASS"
 
 if [ -n "$MAVEN_DEBUG_SCRIPT" ]; then
   echo "[DEBUG] Launching JVM with command:" >&2
-  printf '[DEBUG]   %s' "$cmd" >&2; printf ' "%s"' "$@" >&2; echo >&2
+  printf '[DEBUG]   %s' "$cmd" >&2; printf ' %s' "$MAVEN_ARGS" >&2; printf ' "%s"' "$@" >&2; echo >&2
 fi
 
-# User arguments ("$@") are passed directly to preserve literal values
-# like ${...} Maven property placeholders without shell expansion.
-# Only the base command uses eval for MAVEN_OPTS word splitting.
-eval exec "$cmd" '"$@"'
+# User arguments ("$@") and MAVEN_ARGS are passed outside the eval'd string
+# to preserve literal values (backslashes, ${...} placeholders) without
+# shell re-parsing. Only the base command uses eval for MAVEN_OPTS word splitting.
+eval exec "$cmd" '$MAVEN_ARGS' '"$@"'