Merge "Exclude hashbangs check for .bashrc, .bash_profile, etc"
This commit is contained in:
commit
83611280ed
5
bashate/bashate.py
Normal file → Executable file
5
bashate/bashate.py
Normal file → Executable file
@ -148,8 +148,9 @@ def check_local_subshell(line, report):
|
||||
def check_hashbang(line, filename, report):
|
||||
# this check only runs on the first line
|
||||
# maybe this should check for shell?
|
||||
if not line.startswith("#!") and not filename.endswith(".sh"):
|
||||
report.print_error(MESSAGES['E005'].msg, line)
|
||||
if (not filename.endswith(".sh") and not line.startswith("#!") and
|
||||
not os.path.basename(filename).startswith('.')):
|
||||
report.print_error(MESSAGES['E005'].msg, line)
|
||||
|
||||
|
||||
def check_syntax(filename, report):
|
||||
|
4
bashate/tests/samples/.E005_excluded
Normal file
4
bashate/tests/samples/.E005_excluded
Normal file
@ -0,0 +1,4 @@
|
||||
# this profile/hidden file doesn't start with #!
|
||||
# and doesn't have a .sh extension
|
||||
|
||||
echo hi
|
@ -257,6 +257,12 @@ class TestBashateSamples(base.TestCase):
|
||||
|
||||
self.assert_error_found('E005', 1)
|
||||
|
||||
def test_sample_E005_excluded(self):
|
||||
test_files = ['bashate/tests/samples/.E005_excluded']
|
||||
self.run.check_files(test_files, False)
|
||||
|
||||
self.assertEqual(0, self.run.error_count)
|
||||
|
||||
def test_sample_E040(self):
|
||||
test_files = ['bashate/tests/samples/E040_syntax_error.sh']
|
||||
self.run.register_errors('E040')
|
||||
|
Loading…
Reference in New Issue
Block a user