From cd0845cf35d3f24e9b95df426bc8186d98f5c5df Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jan=20R=C4=99korajski?= Date: Wed, 12 Aug 2020 09:24:51 +0200 Subject: [PATCH] check for bad bash shebangs --- check-shebang.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/check-shebang.py b/check-shebang.py index 0f66385..90075bc 100755 --- a/check-shebang.py +++ b/check-shebang.py @@ -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']) -- 2.43.0