SC2325 – ShellCheck Wiki

See this page on GitHub

Sitemap


Multiple ! in front of pipelines are a bash/ksh extension. Use only 0 or 1.

Problematic code:

#!/bin/sh
! ! true

Correct code:

#!/bin/sh
true

Rationale:

POSIX (and Dash) does not allow multiple ! pipeline negations in a row. It's also logically unnecessary.

Use either zero or one !.

Exceptions:

Scripts whose shebang declares it will run with Ksh and Bash will not trigger this warning.

If you really want to negate multiple times on POSIX or Dash, e.g. to normalize exit codes to 0 or 1, use cmd || false or a command group:

! { ! true; } 

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