mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Fix for shebang with relative bin
`#!/usr/bin/env bin/linguist` is a valid shebang
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user