Skip to content

Files

Latest commit

 

History

History
26 lines (16 loc) · 671 Bytes

SC2038.md

File metadata and controls

26 lines (16 loc) · 671 Bytes

Pattern: Misuse of xargs

Issue: -

Description

By default, xargs interprets spaces and quotes in an unsafe and unexpected way. Whenever it's used, it should be used with -0 or --null to split on \0 bytes, and find should be made to output \0 separated filenames.

POSIX does not require find or xargs to support null terminators, so you can also use find -exec +.

Example of incorrect code:

find . -type f | xargs md5sum

Example of correct code:

find . -type f -print0 | xargs -0 md5sum
find . -type f -exec md5sum {} +

Further Reading