Skip to content
koalaman edited this page Feb 25, 2014 · 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.

Contraindications

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