From 53bb191a5f0e79d6a6d7e59bfc21b33eb9cbfb57 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 23 Jun 2026 07:31:01 +0000 Subject: [PATCH] [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 --- 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 04b149010b0e..85a9a9880535 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' '"$@"'