SC2266
Vidar Holen edited this page Nov 3, 2022
·
1 revision
Use && for logical AND. Single & will background and return true.
Problematic code:
if [ "$1" = "--verbose" ] | [ "$1" = "-v" ]
then
verbose=1
fiCorrect code:
if [ "$1" = "--verbose" ] || [ "$1" = "-v" ]
then
verbose=1
fiRationale:
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!