SC2266 – ShellCheck Wiki

See this page on GitHub

Sitemap


Use && for logical AND. Single & will background and return true.

Problematic code:

if [ "$1" = "--verbose" ] | [ "$1" = "-v" ]
then
  verbose=1
fi

Correct code:

if [ "$1" = "--verbose" ] || [ "$1" = "-v" ]
then
  verbose=1
fi

Rationale:

ShellCheck found a test command followed by a |. This was undoubtedly intended as a logical OR (||).

Exceptions:

None


ShellCheck is a static analysis tool for shell scripts. This page is part of its documentation.