find-xargs-print0
What it does
Section titled “What it does”Reports a pipeline from find into xargs without -print0 and -0.
Why it matters
Section titled “Why it matters”xargs splits its input on blanks and treats quotes and backslashes in it specially, and find writes one file name per line. A file name with a space, a quote or a newline is cut into pieces, and the command runs on wrong files.
To fix, use find ... -print0 | xargs -0 ... (or find -exec).
Example
Section titled “Example”...for f in *.txt; do :; done...find . | xargs rmfind . -print0 | xargs -0 rmfind . | xargs -0 rmfind . -name x | wc -lConfiguration
Section titled “Configuration”shell: lint: rules: find-xargs-print0: warn # off, warn (default), errorEnabled by the presets: shell/shellcheck.
Suppress one line with sudsy-disable-next-line find-xargs-print0 in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools. full: Sudsy reports what the upstream rule reports; partial: only part of it, as the last column says.
| Tool | Rule | Match | What differs |
|---|---|---|---|
| shellcheck | SC2038 |
partial | Only a find ... | xargs pipeline in one statement. |