gnodet-bot commented on code in PR #13652:
URL: https://github.com/apache/maven/pull/13652#discussion_r4334596994
##########
apache-maven/src/assembly/maven/bin/JvmConfigParser.java:
##########
@@ -128,14 +129,40 @@ private static String processLine(String line, String
mavenProjectBasedir) {
}
/**
- * Append parsed arguments as quoted strings to the result builder.
+ * Append parsed arguments in Java @argfile format: one argument per line.
+ * Arguments are quoted when they contain whitespace, double-quotes,
backslashes,
+ * or any shell metacharacter that {@code eval} would re-interpret on Unix
+ * (pipe, ampersand, semicolon, redirection, backtick).
+ * Quoting is always valid in {@code @argfile} format, so this is safe for
+ * both the Windows {@code @argfile} consumer and the Unix {@code eval}
consumer.
*/
private static void appendQuotedArguments(StringBuilder result,
List<String> args) {
for (String arg : args) {
if (result.length() > 0) {
- result.append(' ');
+ result.append(System.lineSeparator());
Review Comment:
⚠️ **Unix regression — newline separator breaks `eval` in `mvn` when
`jvm.config` has 2+ arguments**
On Unix, `JvmConfigParser` is invoked **without** an output file (`args[2]`
not provided), so it writes to stdout (line 78: `System.out.print(result)`).
The Unix `mvn` script's `concat_lines()` captures this stdout and assigns it to
`MAVEN_OPTS`, which is then embedded unquoted in `cmd` and passed to `eval
exec`.
Changing the separator from `' '` to `System.lineSeparator()` means
`MAVEN_OPTS` now contains literal newlines when `jvm.config` has two or more
entries. In `eval`, a newline is a command terminator, so only the first
argument reaches the JVM — the second becomes a separate (failing) command.
Verified with a live test: `eval` returns exit 127 (`-Dfoo=bar: command not
found`) when `MAVEN_OPTS` contains a newline between two args.
The `mvn` Unix script must also be updated to use `@argfile` (pass the temp
file via `@"$tmpfile"`) so the same approach is used on both platforms.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]