-
Notifications
You must be signed in to change notification settings - Fork 1.9k
SC2335
Simon Brandt edited this page Aug 19, 2025
·
2 revisions
and other binary operators such as
-
=
and!=
(string) -
-le
and-gt
, and so forth (arithmetic)
if [ ! "$var" -eq 1 ]; then :; fi
if ! [ "$var" = foo ]; then :; fi
if [ "$var" -ne 1 ]; then :; fi
if [ "$var" != foo ]; then :; fi
Double negation of such binary operators is unnecessary.
This is a stylistic issue that does not affect correctness. If you prefer the original expression, you can Ignore it with a directive or flag.
This rule is not applied to the followings:
-
<
and>
(lexicographical) -
-nt
and-ot
(file timestamp) -
=~
(regular expression)