SC2164
The ShellCheck warning for a cd whose failure is not handled, so the script would carry on in the wrong directory.
In more detail
Write cd dir || exit, or run the script under set -e, so a failed cd stops the script. Otherwise later commands, perhaps an rm, act on files in the wrong directory.
Related terms
- ShellCheck — A linter for shell scripts that reports quoting mistakes, portability problems and common bugs, each with a numbered code.
- cd — The builtin that changes the shell's current working directory.
- OR list — Two commands joined by ||, where the second runs only if the first fails.
Taught in
- ShellCheck — Bash Scripting & Command Line Automation