From aca2503d2b9af090ecaee00c0500be0e19dec655 Mon Sep 17 00:00:00 2001 From: koalaman Date: Sat, 7 Jun 2014 22:31:08 -0700 Subject: [PATCH] Created SC2038 (markdown) --- SC2038.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 SC2038.md 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