changeset 51960:1c23faf64ad4 stable

check-code: document reason and suggest alternative to exit code negation The check was introduced in f48b075ff088. We trust the explanation from there.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 08 Oct 2024 15:54:59 +0200
parents 88715d0bef8d
children a9b1acca2b14
files contrib/check-code.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- 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"),
         (