fix: allow whitespace after the shebang marker. Closes #428.

pull/429/head
Jérôme Alet 3 years ago
parent d0392b34ca
commit 4bfd6d2684
No known key found for this signature in database
GPG Key ID: 68097456F2A988D8

@ -97,7 +97,7 @@ class CommentsTestCase(RuleTestCase):
'#!/bin/env my-interpreter\n'
'', conf,
problem1=(1, 2), problem2=(3, 2), problem3=(4, 2))
self.check('#! not a shebang\n',
self.check('#! is a valid shebang too\n',
conf, problem1=(1, 2))
self.check('key: #!/not/a/shebang\n',
conf, problem1=(1, 8))
@ -117,8 +117,7 @@ class CommentsTestCase(RuleTestCase):
'#comment\n'
'#!/bin/env my-interpreter\n', conf,
problem2=(3, 2), problem3=(4, 2))
self.check('#! not a shebang\n',
conf, problem1=(1, 2))
self.check('#! is a valid shebang too\n', conf)
self.check('key: #!/not/a/shebang\n',
conf, problem1=(1, 8))

@ -105,7 +105,7 @@ def check(conf, comment):
if (conf['ignore-shebangs'] and
comment.line_no == 1 and
comment.column_no == 1 and
re.match(r'^!\S', comment.buffer[text_start:])):
comment.buffer[text_start:].startswith('!')):
return
# We can test for both \r and \r\n just by checking first char
# \r itself is a valid newline on some older OS.

Loading…
Cancel
Save