Description
The "portable `sed -i` (GNU vs BSD)" helper is duplicated across three tracer scripts in `tests/benchmarks/resolution/tracer/`:
- `native-tracer.sh` (lines 32-39): named function `sedi()`
- `jvm-tracer.sh` (lines 52-58): byte-identical named function `sedi()`
- `go-tracer.sh` (lines 139-143, 147-159): the same `sed --version 2>/dev/null | grep -q GNU` branch inlined twice within the same file (once for per-file function injection, once for the `main()` defer injection), instead of extracting a helper at all
```bash
sedi() {
if sed --version 2>/dev/null | grep -q GNU; then
sed -i "$@"
else
sed -i '' "$@"
fi
}
```
Why this wasn't fixed inline
Found during Titan grind phase 29 (forge commit 8386f71) while running the mandatory codebase-wide duplicate-logic scan for that phase's extracted helpers (`inject_trace_calls`, matcher functions in `loader-hooks.mjs`). This `sedi()` duplication predates phase 29's commit — it was not created or modified by it — so it's out of scope for that grind pass per the one-concern-per-change rule.
Consolidating it also isn't a simple "adopt a helper already in the same file" grind action: these are three independent, separately-invoked bash scripts (each is spawned as its own process by the benchmark harness), so sharing `sedi()` requires extracting it into a new sourced file (e.g. `tracer-common.sh`) that each script sources — a small structural change, but a distinct concern from this phase's work.
Suggested fix
Extract `sedi()` into a shared `tests/benchmarks/resolution/tracer/tracer-common.sh`, have `native-tracer.sh`, `jvm-tracer.sh`, and `go-tracer.sh` source it, and remove the inline duplicates (including the two inlined copies in `go-tracer.sh` itself).
Description
The "portable `sed -i` (GNU vs BSD)" helper is duplicated across three tracer scripts in `tests/benchmarks/resolution/tracer/`:
```bash
sedi() {
if sed --version 2>/dev/null | grep -q GNU; then
sed -i "$@"
else
sed -i '' "$@"
fi
}
```
Why this wasn't fixed inline
Found during Titan grind phase 29 (forge commit 8386f71) while running the mandatory codebase-wide duplicate-logic scan for that phase's extracted helpers (`inject_trace_calls`, matcher functions in `loader-hooks.mjs`). This `sedi()` duplication predates phase 29's commit — it was not created or modified by it — so it's out of scope for that grind pass per the one-concern-per-change rule.
Consolidating it also isn't a simple "adopt a helper already in the same file" grind action: these are three independent, separately-invoked bash scripts (each is spawned as its own process by the benchmark harness), so sharing `sedi()` requires extracting it into a new sourced file (e.g. `tracer-common.sh`) that each script sources — a small structural change, but a distinct concern from this phase's work.
Suggested fix
Extract `sedi()` into a shared `tests/benchmarks/resolution/tracer/tracer-common.sh`, have `native-tracer.sh`, `jvm-tracer.sh`, and `go-tracer.sh` source it, and remove the inline duplicates (including the two inlined copies in `go-tracer.sh` itself).