check-code: document reason and suggest alternative to exit code negation stable
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 08 Oct 2024 15:54:59 +0200
branchstable
changeset 51960 1c23faf64ad4
parent 51959 88715d0bef8d
child 51961 a9b1acca2b14
check-code: document reason and suggest alternative to exit code negation The check was introduced in f48b075ff088. We trust the explanation from there.
contrib/check-code.py
--- a/contrib/check-code.py	Tue Oct 08 15:54:59 2024 +0200
+++ b/contrib/check-code.py	Tue Oct 08 15:54:59 2024 +0200
@@ -161,7 +161,11 @@
         (r'(\[|\btest\b).*-e ', "don't use 'test -e', use 'test -f'"),
         (r'\[\[\s+[^\]]*\]\]', "don't use '[[ ]]', use '[ ]'"),
         (r'^alias\b.*=', "don't use alias, use a function"),
-        (r'if\s*!', "don't use '!' to negate exit status"),
+        # Solaris sh can not negate exit status with '!'
+        (
+            r'if\s*!',
+            "don't use '!' to negate exit status (use `||` or if/else)",
+        ),
         (r'/dev/u?random', "don't use entropy, use /dev/zero"),
         (r'do\s*true;\s*done', "don't use true as loop body, use sleep 0"),
         (