Skip to content
Vidar Holen edited this page Jan 21, 2015 · 7 revisions

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.

Exceptions

None

ShellCheck

Each individual ShellCheck warning has its own wiki page like SC1000. Use GitHub Wiki's "Pages" feature above to find a specific one, or see Checks.

Clone this wiki locally