diff --git a/SC2060.md b/SC2060.md new file mode 100644 index 0000000..d8ba88f --- /dev/null +++ b/SC2060.md @@ -0,0 +1,17 @@ +# Quote parameters to tr to prevent glob expansion. + +### Problematic code: + + tr -cd [:digit:] + +### Correct code: + + tr -cd '[:digit:]' + +### Rationale: + +`[:digit:]` is a shell glob that matches any single character file named e.g. `g` or `t` in the current directory. Quoting it prevents the script from breaking in directories with files like this. + +### Contraindications + +None \ No newline at end of file