Patchwork D609: check-code: forbid using bash in shebang

login
register
mail settings
Submitter phabricator
Date Sept. 3, 2017, 2:20 p.m.
Message ID <6398699c684f1e0855954ca94d205cbf@localhost.localdomain>
Download mbox | patch
Permalink /patch/23633/
State Not Applicable
Headers show

Comments

phabricator - Sept. 3, 2017, 2:20 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGe267d4ee4f2d: check-code: forbid using bash in shebang (authored by quark).

CHANGED PRIOR TO COMMIT
  https://phab.mercurial-scm.org/D609?vs=1566&id=1586#toc

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D609?vs=1566&id=1586

REVISION DETAIL
  https://phab.mercurial-scm.org/D609

AFFECTED FILES
  contrib/check-code.py

CHANGE DETAILS




To: quark, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/contrib/check-code.py b/contrib/check-code.py
--- a/contrib/check-code.py
+++ b/contrib/check-code.py
@@ -119,7 +119,8 @@ 
     (r'\[[^\]]+==', '[ foo == bar ] is a bashism, use [ foo = bar ] instead'),
     (r'(^|\|\s*)grep (-\w\s+)*[^|]*[(|]\w',
      "use egrep for extended grep syntax"),
-    (r'/bin/', "don't use explicit paths for tools"),
+    (r'(?<!!)/bin/', "don't use explicit paths for tools"),
+    (r'#!.*/bash', "don't use bash in shebang, use sh"),
     (r'[^\n]\Z', "no trailing newline"),
     (r'export .*=', "don't export and assign at once"),
     (r'^source\b', "don't use 'source', use '.'"),
@@ -159,7 +160,7 @@ 
 ]
 
 testfilters = [
-    (r"( *)(#([^\n]*\S)?)", repcomment),
+    (r"( *)(#([^!][^\n]*\S)?)", repcomment),
     (r"<<(\S+)((.|\n)*?\n\1)", rephere),
 ]
 
@@ -232,7 +233,7 @@ 
 
 utestfilters = [
     (r"<<(\S+)((.|\n)*?\n  > \1)", rephere),
-    (r"( +)(#([^\n]*\S)?)", repcomment),
+    (r"( +)(#([^!][^\n]*\S)?)", repcomment),
 ]
 
 pypats = [