check for bad bash shebangs
authorJan Rękorajski <baggins@pld-linux.org>
Wed, 12 Aug 2020 07:24:51 +0000 (09:24 +0200)
committerJan Rękorajski <baggins@pld-linux.org>
Wed, 12 Aug 2020 07:24:51 +0000 (09:24 +0200)
check-shebang.py

index 0f66385477da031135c37240e72d343d0caf80ca..90075bc28f7b155bc0ef357609d2d608c225d200 100755 (executable)
@@ -19,6 +19,7 @@ rep = {
     'python3': [],
     'perl': [],
     'ruby': [],
+    'bash': [],
 }
 
 skip_files = [".h", ".c", ".cc", ".gif", ".png", ".jpg", ".ko", ".gz", ".o"]
@@ -71,6 +72,8 @@ for root, dirs, files in os.walk(args.sourcedir):
                     rep['perl'].append(fpath)
                 elif re.compile(r'^#!\s*/usr/bin/env\s+ruby\s').match(shebang):
                     rep['ruby'].append(fpath)
+                elif re.compile(r'^#!\s*/usr/bin/env\s+bash\s').match(shebang):
+                    rep['bash'].append(fpath)
         except FileNotFoundError:
             pass
 
@@ -98,3 +101,4 @@ gf("%{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+python2(\s|$),#!%{__python}\\1,' -
 gf("%{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+python3(\s|$),#!%{__python3}\\1,' \\", rep['python3'])
 gf("%{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+perl(\s|$),#!%{__perl}\\1,' \\", rep['perl'])
 gf("%{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+ruby(\s|$),#!%{__ruby}\\1,' \\", rep['ruby'])
+gf("%{__sed} -E -i -e '1s,#!\s*/usr/bin/env\s+bash(\s|$),#!/bin/bash\\1,' \\", rep['bash'])
This page took 0.155479 seconds and 4 git commands to generate.