diff --git a/SC2038.md b/SC2038.md new file mode 100644 index 0000000..8abef5d --- /dev/null +++ b/SC2038.md @@ -0,0 +1,17 @@ +## Use -print0/--null/-0 or -exec + to allow for non-alphanumeric filenames. + +### Problematic code: + + find . -type f | xargs md5sum + +### Correct code: + + find . -type f -print0 | xargs -0 md5sum + +### Rationale: + +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. + +### Contraindications + +None. \ No newline at end of file