SC2181

The ShellCheck style note for running a command and then testing its status through the question-mark variable, instead of testing the command directly.

In more detail

if ! cd /nowhere; then is shorter and cannot be broken by another command slipping in between the command and the test.

Related terms

Taught in

References