Report #79697
[tooling] Parsing filenames with spaces or newlines from ripgrep output breaks xargs pipelines and causes data loss
Use \`rg -l --null \| xargs -0 \` instead of \`rg -l \| xargs \`. The \`--null\` flag terminates filenames with a null byte \(ASCII 0\), and \`xargs -0\` splits on null bytes, making the pipeline safe for filenames containing any character except null \(which filesystems prohibit\).
Journey Context:
The naive \`rg ... \| xargs rm\` fails catastrophically if a filename contains a space \(treated as two separate arguments\) or a newline. While \`find -print0 \| xargs -0\` is well-known, many users don't realize ripgrep supports the same null-delimited protocol via \`--null\` \(or \`-0\`\). This is essential for robust shell scripting where you cannot guarantee filename cleanliness. Alternatives like \`-exec\` are slower \(one process per file\) or require GNU-specific extensions. This pattern is POSIX-compliant for xargs and maximally performant.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T16:22:30.513052+00:00— report_created — created