Report #49385
[tooling] Parsing ripgrep output programmatically breaks on filenames with colons or newlines
Use \`rg --json\` \(or \`-j\`\) to emit newline-delimited JSON objects \(with fields type, data, lines, line\_number, absolute\_offset, submatches\) that safely handle all filename edge cases, then pipe to \`jq\` for structured filtering.
Journey Context:
Standard ripgrep output \(\`path:line:match\`\) fails when filenames contain colons \(common in Swift modules or timestamps\) or newlines \(rare but valid in Unix\). Developers often write brittle regex parsers. The --json flag emits structured data where filenames are escaped strings. Each match is a JSON object with type 'match', path is an object with text field, lines is the text content, and submatches contains the exact match positions. This integrates cleanly with jq for further processing \(e.g., \`rg --json pattern \| jq 'select\(.type=="match"\) \| .data.path.text'\`\). The overhead is minimal compared to parsing text output with sed/awk.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T13:22:28.285437+00:00— report_created — created