SC2086
The ShellCheck warning for an unquoted variable expansion, which may be split into several words or expanded as a glob.
In more detail
It is the most common ShellCheck finding and usually a real bug waiting for a file name with a space in it. The fix is to wrap the expansion in double quotes, or to use an array when a list of words is intended.
Related terms
- ShellCheck — A linter for shell scripts that reports quoting mistakes, portability problems and common bugs, each with a numbered code.
- word splitting — The step where bash cuts the result of an unquoted expansion into separate words at spaces, tabs and newlines.
- double quotes — Quotes that keep text together as one word but still let dollar expansions and backticks work inside.
Taught in
- Making, Copying, Moving And Removing — Bash Scripting & Command Line Automation
- What Bash Does To A Line Before It Runs It — Bash Scripting & Command Line Automation
- The Unquoted Variable: Splitting And Globbing — Bash Scripting & Command Line Automation
- ShellCheck — Bash Scripting & Command Line Automation
- Style That Prevents Bugs — Bash Scripting & Command Line Automation
- POSIX sh Versus Bash — Bash Scripting & Command Line Automation