From 01122d5594d982818119a0c75d9191215b180360 Mon Sep 17 00:00:00 2001 From: koalaman Date: Mon, 24 Feb 2014 17:55:43 -0800 Subject: [PATCH] Created SC2060 (markdown) --- SC2060.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 SC2060.md 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