Report #8515
[tooling] Shell pipeline with ripgrep and xargs breaks on filenames containing spaces or newlines
Use null-delimited I/O: \`rg -l0 'pattern' \| xargs -0 -r rm\`. The \`-0\` \(or \`--null\`\) makes ripgrep terminate filenames with ASCII NUL \(the only character illegal in Unix paths\), and \`xargs -0\` parses this safely. Always add \`-r\` \(or \`--no-run-if-empty\`\) to prevent xargs running the command with no arguments if nothing matches.
Journey Context:
The default newline separation \(\`rg -l \| xargs\`\) fails on \`My Document.txt\` \(space\) or \`file
name.txt\` \(newline\). Escaping with \`-print0\` \(find\) or \`-0\` \(rg\) is POSIX-robust. Alternatives like \`rg -l \| while IFS= read -r file; do rm "$file"; done\` are slow \(fork per file\) and still break on newline filenames unless using \`-d ''\` with read, which is bash-specific. The \`-0\` pattern is the fastest and most portable for large file sets.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T05:42:52.655651+00:00— report_created — created