Commit 53ebe43
committed
fix(java_opts): handle multiple \$JAVA_OPTS in one opts file; fix %% in fmt.Sprintf
Two bugs fixed:
1. The if-guard (single replacement) became a bounded for-loop so opts files
with $JAVA_OPTS more than once are handled correctly. Scenario: a user sets
JBP_CONFIG_JAVA_OPTS: '{java_opts: "$JAVA_OPTS -Xmx512m", from_environment: true}'
which produces "$JAVA_OPTS -Xmx512m $JAVA_OPTS" in the opts file — two placeholders.
2. The _before cut used %% in the Go fmt.Sprintf template, which emits a
single % in the generated bash (shortest-suffix removal). With two
placeholders, % cuts from the wrong side, leaving placeholders in place.
Changed to %%%% in Go source → %% in bash (longest-suffix removal) so
each for-loop iteration always removes from the first occurrence.
Test added (TDD): "replaces all occurrences of $JAVA_OPTS when opts file
contains it twice" — was red before both fixes, green after.
Also: scripts/unit.sh: use ${BASH_VERSION} builtin instead of bash --version
pipe (Copilot review comment 2).1 parent 86684bc commit 53ebe43
3 files changed
Lines changed: 21 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
200 | | - | |
201 | | - | |
202 | | - | |
203 | | - | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
204 | 209 | | |
205 | 210 | | |
206 | | - | |
| 211 | + | |
207 | 212 | | |
208 | 213 | | |
209 | 214 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
373 | 382 | | |
374 | 383 | | |
375 | 384 | | |
| |||
0 commit comments