Created SC2038 (markdown)

koalaman
2014-06-07 22:31:08 -07:00
parent 1494c00aae
commit aca2503d2b

17
SC2038.md Normal file

@@ -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.