From 6f6b8124237da97c7e364d529160d565f7955b2e Mon Sep 17 00:00:00 2001 From: Vidar Holen Date: Sun, 13 Jan 2019 15:26:41 -0800 Subject: [PATCH] Updated SC2060 (markdown) --- SC2060.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SC2060.md b/SC2060.md index 1b0ca2c..6f858a7 100644 --- a/SC2060.md +++ b/SC2060.md @@ -14,9 +14,9 @@ tr -cd '[:digit:]' ### Rationale: -From the shell's point of view, unquoted `[:digit:]` is glob equivalent to `[dgit:]` that matches any single character filename from the group, such as `g` or `t`, in the current directory. +From the shell's point of view, unquoted `[:digit:]` is a glob equivalent to `[dgit:]` that matches any single character filename from the group, such as `d` or `t`, in the current directory. -If someone starts learning D and creates a directory named `d` to hold the source code, the glob will be expanded and the script will end up executing `tr -cd d`, which is clearly unintended. +If someone starts learning D and creates a directory named `d` to hold the source code, the glob will be expanded and the script will end up executing `tr -cd d` instead, which is clearly unintended. Quoting the argument prevents this, and will pass it correctly as the literal string `[:digit:]` no matter which files exist in the current directory.