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