gnodet opened a new pull request, #11365:
URL: https://github.com/apache/maven/pull/11365
## Description
Fixes #11363
This PR fixes the issue where Maven 4 fails to parse pipe symbols (`|`) in
`.mvn/jvm.config` files, causing shell command parsing errors.
## Problem
When users tried to use JVM arguments with pipe symbols in
`.mvn/jvm.config`, such as:
```
-Dhttp.nonProxyHosts=de|*.de|my.company.mirror.de
```
Maven 4 would fail with errors like:
```bash
*.de: command not found
my.company.mirror.de: command not found
```
## Root Cause
The `concat_lines` function in the Unix shell script
(`apache-maven/src/assembly/maven/bin/mvn`) was using `xargs -n 1` to split
arguments by whitespace. This broke quoted arguments containing pipe symbols,
which were then interpreted as shell command separators during the `eval exec`
command execution.
## Solution
Replaced the problematic `concat_lines` function with a more robust
implementation that:
1. **Preserves quoted arguments**: Reads the file line by line without
splitting on whitespace within quotes
2. **Maintains pipe symbols**: Doesn't treat pipe symbols as special shell
characters
3. **Keeps existing functionality**: Still removes comments, empty lines,
and performs variable substitution
4. **Maintains compatibility**: Works with all existing jvm.config scenarios
## Testing
Added comprehensive integration test
(`MavenITmng11363PipeSymbolsInJvmConfigTest`) that verifies:
✅ Pipe symbols are preserved in JVM arguments
✅ Quoted spaces work correctly
✅ Variable substitution (`${MAVEN_PROJECTBASEDIR}` and
`$MAVEN_PROJECTBASEDIR`) works
✅ Complex scenarios with pipes and spaces work
✅ Comments are properly removed
✅ Regular JVM options work as expected
✅ No shell parsing errors occur
## Compatibility
- **Windows script unaffected**: The Windows `mvn.cmd` script already
handled this correctly
- **Existing functionality preserved**: All existing jvm.config features
continue to work
- **Backward compatible**: No breaking changes to existing configurations
- **Code formatting**: Passes all spotless formatting checks
## Changes
- Modified `apache-maven/src/assembly/maven/bin/mvn` - Fixed the
`concat_lines` function
- Added integration test with test resources to verify the fix
---
Pull Request opened by [Augment Code](https://www.augmentcode.com/) with
guidance from the PR author
--
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]