mirror of https://github.com/zulip/zulip.git
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:
parent
dfbea01c8f
commit
df4d1b3c14
|
@ -76,6 +76,8 @@ for filepath in files:
|
||||||
|
|
||||||
by_lang[exn].append(filepath)
|
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,
|
# Invoke the appropriate lint checker for each language,
|
||||||
# and also check files for extra whitespace.
|
# and also check files for extra whitespace.
|
||||||
|
|
||||||
|
@ -169,6 +171,10 @@ python_rules = [
|
||||||
python_line_skip_rules = [
|
python_line_skip_rules = [
|
||||||
'\s*[*#]', # comments
|
'\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():
|
def check_custom_checks():
|
||||||
failed = False
|
failed = False
|
||||||
|
@ -181,6 +187,10 @@ def check_custom_checks():
|
||||||
if custom_check_file(fn, js_rules):
|
if custom_check_file(fn, js_rules):
|
||||||
failed = True
|
failed = True
|
||||||
|
|
||||||
|
for fn in by_lang['.sh']:
|
||||||
|
if custom_check_file(fn, bash_rules):
|
||||||
|
failed = True
|
||||||
|
|
||||||
return failed
|
return failed
|
||||||
|
|
||||||
lint_functions = {}
|
lint_functions = {}
|
||||||
|
|
Loading…
Reference in New Issue