Add linting code for detecting shebang bashisms.

This will prevent regressions in OpenBSD compatibility, since OpenBSD
doesn't support passing arguments in the #! line.
This commit is contained in:
Vladislav Manchev 2016-01-17 18:24:31 +02:00 committed by Tim Abbott
parent dfbea01c8f
commit df4d1b3c14
1 changed files with 10 additions and 0 deletions

View File

@ -76,6 +76,8 @@ for filepath in files:
by_lang[exn].append(filepath)
by_lang['.sh'] = filter(None, map(str.strip, subprocess.check_output("grep --files-with-matches '#!.*\(ba\)\?sh' $(find scripts/ tools/ bin/ -type f | grep -v [.])", shell=True).split('\n')))
# Invoke the appropriate lint checker for each language,
# and also check files for extra whitespace.
@ -169,6 +171,10 @@ python_rules = [
python_line_skip_rules = [
'\s*[*#]', # comments
]
bash_rules = [
{'pattern': '#!.*sh [-xe]',
'description': 'Fix shebang line with proper call to /usr/bin/env for Bash path, change -x|-e switches to set -x|set -e'},
]
def check_custom_checks():
failed = False
@ -181,6 +187,10 @@ def check_custom_checks():
if custom_check_file(fn, js_rules):
failed = True
for fn in by_lang['.sh']:
if custom_check_file(fn, bash_rules):
failed = True
return failed
lint_functions = {}