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 - .cr
ace_mode: ruby ace_mode: ruby
tm_scope: source.ruby tm_scope: source.ruby
interpreters:
- crystal
Cucumber: Cucumber:
extensions: extensions:

View File

@@ -133,6 +133,9 @@ module Linguist
script = script == 'env' ? tokens[1] : script script = script == 'env' ? tokens[1] : script
# If script has an invalid shebang, we might get here
return unless script
# "python2.6" -> "python2" # "python2.6" -> "python2"
script.sub! $1, '' if script =~ /(\.\d+)$/ script.sub! $1, '' if script =~ /(\.\d+)$/
@@ -142,7 +145,7 @@ module Linguist
script = $1 script = $1
end end
script File.basename(script)
else else
nil nil
end end

View File

@@ -85,4 +85,9 @@ class TestSamples < Test::Unit::TestCase
end end
end end
end end
def test_shebang
assert_equal "crystal", Linguist.interpreter_from_shebang("#!/usr/bin/env bin/crystial")
assert_equal "python2", Linguist.interpreter_from_shebang("#!/usr/bin/python2.4")
end
end end