mirror of
https://github.com/adrienverge/yamllint.git
synced 2024-11-22 07:36:25 -06:00
comments: Allow whitespace after the shebang marker
Basically, any character is now allowed after the shebang marker. Closes #428. Whitespace after the #! marker on shebang lines is authorized and optional, as explained on Wikipedia's entry for shebang line as can be seen from the extracts below : > White space after #! is optional and > It has been claimed[20] that some old versions of Unix expect the > normal shebang to be followed by a space and a slash (#! /), but this > appears to be untrue;[21] rather, blanks after the shebang have > traditionally been allowed, and sometimes documented with a space
This commit is contained in:
parent
d0392b34ca
commit
bb567ba395
@ -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))
|
||||
|
||||
|
@ -74,8 +74,6 @@ Use this rule to control the position and formatting of comments.
|
||||
"""
|
||||
|
||||
|
||||
import re
|
||||
|
||||
from yamllint.linter import LintProblem
|
||||
|
||||
|
||||
@ -105,7 +103,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] == '!'):
|
||||
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…
Reference in New Issue
Block a user