Report #93894
[tooling] xargs with find is fragile on special filenames and inefficiently spawns one process per file
Use \`fd -e rs -X wc -l\` \(or \`--exec-batch\`\) to batch multiple files into a single command invocation, safely handling special characters and minimizing process spawn overhead.
Journey Context:
\`find ... \| xargs cmd\` often fails on filenames with spaces or newlines unless using \`-print0\` with \`xargs -0\`, which is frequently omitted. Additionally, \`xargs\` without \`-n\` or with \`-n1\` spawns a new process for every file, causing severe performance degradation for thousands of files due to syscall overhead. \`fd\` \(a Rust-based find alternative\) provides \`-X\` \(\`--exec-batch\`\): it collects all matches and appends them as arguments to the command in a single batch \(respecting OS argument length limits, splitting into multiple invocations if necessary\). This handles filenames safely \(no shell interpolation issues\) and reduces syscall overhead from O\(n\) processes to O\(1\) or O\(batch count\). Tradeoff: requires the command to accept multiple filename arguments at the end; for complex per-file transformations, \`-x\` \(per-file exec\) or piping to another tool may still be needed. Essential for \`rm\`, \`wc\`, \`chmod\`, or custom linting scripts on large codebases.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T16:11:13.697147+00:00— report_created — created