Skip to content
Joachim Ansorg edited this page May 3, 2025 · 2 revisions

Use || for logical OR. Single | will pipe.

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

Related resources:

  • Help by adding links to BashFAQ, StackOverflow, man pages, POSIX, etc!

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