Fix for shebang with relative bin

`#!/usr/bin/env bin/linguist` is a valid shebang
This commit is contained in:
Brandon Keepers
2014-11-20 12:50:35 -05:00
parent 45384bd498
commit 9823af0cb4
3 changed files with 12 additions and 2 deletions

View File

@@ -544,6 +544,8 @@ Crystal:
- .cr
ace_mode: ruby
tm_scope: source.ruby
interpreters:
- crystal
Cucumber:
extensions:

View File

@@ -133,6 +133,9 @@ module Linguist
script = script == 'env' ? tokens[1] : script
# If script has an invalid shebang, we might get here
return unless script
# "python2.6" -> "python2"
script.sub! $1, '' if script =~ /(\.\d+)$/
@@ -141,8 +144,8 @@ module Linguist
lines[0...5].any? { |l| l.match(/exec (\w+).+\$0.+\$@/) }
script = $1
end
script
File.basename(script)
else
nil
end