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!
Clone this wiki locally