From: Jan Rękorajski Date: Wed, 12 Aug 2020 07:24:51 +0000 (+0200) Subject: check for bad bash shebangs X-Git-Tag: auto/th/rpm-build-tools-4.9-7~2 X-Git-Url: http://git.pld-linux.org/?p=packages%2Frpm-build-tools.git;a=commitdiff_plain;h=cd0845cf35d3f24e9b95df426bc8186d98f5c5df check for bad bash shebangs --- 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'])