[2.x] fix: Handle JVM parameters with spaces in dot files#8730
Merged
eed3si9n merged 3 commits intosbt:developfrom Feb 14, 2026
Merged
[2.x] fix: Handle JVM parameters with spaces in dot files#8730eed3si9n merged 3 commits intosbt:developfrom
eed3si9n merged 3 commits intosbt:developfrom
Conversation
eed3si9n
requested changes
Feb 13, 2026
9a26d61 to
e3ed1a1
Compare
Contributor
Author
|
Hi, @eed3si9n , Please check my updates if you have time. Thank you. |
Contributor
Author
|
Hi, @eed3si9n , Thank you for your review. Could you merge this PR? |
eed3si9n
pushed a commit
to eed3si9n/sbt
that referenced
this pull request
Feb 14, 2026
**Problem** The sbt launcher script used naive word splitting when parsing `.sbtopts` and `.jvmopts`, so arguments with spaces were split incorrectly. For example, `-J--add-modules jdk.incubator.concurrent` in `.sbtopts` and `-Dtest.key="value with spaces"` in `.jvmopts` were not passed to the JVM as intended.
eed3si9n
added a commit
that referenced
this pull request
Feb 14, 2026
) **Problem** The sbt launcher script used naive word splitting when parsing `.sbtopts` and `.jvmopts`, so arguments with spaces were split incorrectly. For example, `-J--add-modules jdk.incubator.concurrent` in `.sbtopts` and `-Dtest.key="value with spaces"` in `.jvmopts` were not passed to the JVM as intended. Co-authored-by: PandaMan <[email protected]>
njlazzar-su
pushed a commit
to njlazzar-su/sbt
that referenced
this pull request
Feb 17, 2026
**Problem** After PR sbt#8730 (commit 921efce), inline comments in .jvmopts and .sbtopts files cause errors. For example, `--add-opens=java.base/java.util=ALL-UNNAMED # comment` results in: Error: Could not find or load main class # The # and everything after it is now parsed as separate arguments instead of being stripped as a comment. **Solution** Update the sed command in outputConfigFileTokens() to strip inline comments (everything from # to end of line) before parsing tokens. Changed: sed $'/^\#/d;s/\r$//' To: sed $'/^\#/d;s/\s*\#.*//;s/\r$//' The new s/\s*\#.*// pattern matches optional whitespace + # + rest of line and removes it. **Testing** - Added integration test verifying inline comments are stripped from .jvmopts - Manually tested with .jvmopts containing inline comments - no errors - Full line comments (starting with #) still work correctly Generated-by: Claude Sonnet 4.5
eed3si9n
pushed a commit
that referenced
this pull request
Feb 17, 2026
) **Problem** After PR #8730 (commit 921efce), inline comments in .jvmopts and .sbtopts files cause errors. For example, `--add-opens=java.base/java.util=ALL-UNNAMED # comment` results in: Error: Could not find or load main class # The # and everything after it is now parsed as separate arguments instead of being stripped as a comment. **Solution** Update the sed command in outputConfigFileTokens() to strip inline comments (everything from # to end of line) before parsing tokens. The new s/\s*\#.*// pattern matches optional whitespace + # + rest of line and removes it. Generated-by: Claude Sonnet 4.5
eed3si9n
added a commit
to eed3si9n/sbt
that referenced
this pull request
Feb 23, 2026
eed3si9n
added a commit
to eed3si9n/sbt
that referenced
this pull request
Feb 23, 2026
eed3si9n
added a commit
that referenced
this pull request
Feb 23, 2026
eed3si9n
added a commit
that referenced
this pull request
Feb 23, 2026
This was referenced Feb 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7333
Problem
The sbt launcher script used naive word splitting when parsing
.sbtoptsand.jvmopts, so arguments with spaces were split incorrectly. For example,-J--add-modules jdk.incubator.concurrentin.sbtoptsand-Dtest.key="value with spaces"in.jvmoptswere not passed to the JVM as intended.Solution
Parsing was updated to be quote-aware. A new
parseLineIntoWords()helper splits lines while respecting single and double quotes.loadConfigFileIntoArray()loads config files into bash arrays: for-Jlines it splits the remainder and prepends-Jto each token (e.g.-J--add-modules jdk.incubator.concurrent→-J--add-modulesand-Jjdk.incubator.concurrent); for other lines it uses quote-aware splitting..sbtoptsnow usesloadConfigFileIntoArrayinstead ofloadConfigFile;.jvmoptsusesloadConfigFileIntoArrayand merges the result intojava_argsinstead of appending viaJAVA_OPTSstring concatenation.Testing
Two integration tests were added in
RunnerScriptTest.scala: one for-J--add-modules jdk.incubator.concurrentin.sbtopts, and one for-Dtest.7333="value with spaces"in.jvmopts, both verifying that the full values are passed correctly to the JVM.