Fix detection for invalid shebang

This commit is contained in:
Brandon Keepers
2014-12-02 21:03:39 -06:00
parent 39037d5bfb
commit a5673e7fb6
2 changed files with 2 additions and 1 deletions

View File

@@ -19,7 +19,7 @@ module Linguist
# Returns a String or nil
def self.interpreter(data)
lines = data.lines
return unless match = /^#! ?(.*)$/.match(lines.first)
return unless match = /^#! ?(.+)$/.match(lines.first)
tokens = match[1].split(' ')
script = tokens.first.split('/').last

View File

@@ -16,6 +16,7 @@ class TestShebang < Test::Unit::TestCase
assert_interpreter nil, "\n\n\n\n\n"
assert_interpreter nil, " #!/usr/sbin/ruby"
assert_interpreter nil, "\n#!/usr/sbin/ruby"
assert_interpreter nil, "#!"
assert_interpreter "ruby", "#!/usr/sbin/ruby\n# bar"
assert_interpreter "ruby", "#!/usr/bin/ruby\n# foo"