mirror of
https://github.com/koalaman/shellcheck.git
synced 2025-10-03 19:29:44 +08:00
Created SC2038 (markdown)
17
SC2038.md
Normal file
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.
|
Reference in New Issue
Block a user