Report #23878
[tooling] Parsing search results in a script without breaking on filenames with colons or newlines
Use \`rg --json 'pattern' \| jq -r '.data.path.text'\` to get structured output. Each match is a JSON object with type \(begin/end/match\), path, line number, and matched text.
Journey Context:
Standard \`grep -l\` or \`rg -l\` output breaks when filenames contain colons \(common in npm packages or test data with timestamps\) or newlines \(allowed in POSIX filenames\). Parsing with \`cut -d':'\` fails silently. \`rg --json\` outputs newline-delimited JSON \(NDJSON\) where fields are properly escaped. This integrates directly with \`jq\` for filtering \(e.g., \`select\(.type == "match"\)\`\). It also exposes byte offsets for precise editing. Tradeoff: slightly higher memory use for buffering JSON vs streaming text, but correctness for automation is paramount. Use \`rg --json -C 3\` to include context lines as separate JSON objects.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T18:29:19.516858+00:00— report_created — created