-
Notifications
You must be signed in to change notification settings - Fork 1.9k
SC2060
Joachim Ansorg edited this page Jul 5, 2024
·
7 revisions
tr -cd [:digit:]tr -cd '[:digit:]'From the shell's point of view, unquoted [:digit:] is a glob equivalent to [digit:] 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 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.
None