Merge branch 'master' into add-proximity-test

This commit is contained in:
Garen Torikian
2015-04-02 17:32:00 -07:00
12 changed files with 2137 additions and 8 deletions

View File

@@ -28,6 +28,7 @@
ABAP:
type: programming
color: "#E8274B"
extensions:
- .abap
ace_mode: abap
@@ -337,6 +338,7 @@ Boo:
Brainfuck:
type: programming
color: "#2F2530"
extensions:
- .b
- .bf
@@ -643,6 +645,7 @@ Creole:
Crystal:
type: programming
color: "#76EEF5"
extensions:
- .cr
ace_mode: ruby
@@ -869,6 +872,10 @@ Erlang:
- .es
- .escript
- .hrl
filenames:
- rebar.config
- rebar.config.lock
- rebar.lock
ace_mode: erlang
interpreters:
- escript
@@ -1564,6 +1571,7 @@ Kit:
Kotlin:
type: programming
color: "#EA4DFA"
extensions:
- .kt
- .ktm
@@ -1781,6 +1789,7 @@ MUF:
Makefile:
type: programming
color: "#427819"
aliases:
- bsdmake
- make
@@ -2930,6 +2939,7 @@ Shell:
- .fcgi
- .ksh
- .tmux
- .tool
- .zsh
interpreters:
- bash

View File

@@ -23,17 +23,20 @@ module Linguist
# First line must start with #!
return unless shebang && shebang.start_with?("#!")
# Get the parts of the shebang without the #!
tokens = shebang.sub(/^#!\s*/, '').strip.split(' ')
s = StringScanner.new(shebang)
# There was nothing after the #!
return if tokens.empty?
return unless path = s.scan(/^#!\s*\S+/)
# Get the name of the interpreter
script = File.basename(tokens.first)
# Keep going
script = path.split('/').last
# Get next argument if interpreter was /usr/bin/env
script = tokens[1] if script == 'env'
# if /usr/bin/env type shebang then walk the string
if script == 'env'
s.scan(/\s+/)
s.scan(/.*=[^\s]+\s+/) # skip over variable arguments e.g. foo=bar
script = s.scan(/\S+/)
end
# Interpreter was /usr/bin/env with no arguments
return unless script
@@ -41,6 +44,9 @@ module Linguist
# "python2.6" -> "python2"
script.sub! /(\.\d+)$/, ''
# #! perl -> perl
script.sub! /^#!\s*/, ''
# Check for multiline shebang hacks that call `exec`
if script == 'sh' &&
data.lines.first(5).any? { |l| l.match(/exec (\w+).+\$0.+\$@/) }

View File

@@ -22,8 +22,10 @@ module Linguist
# Start state on token, ignore anything till the next newline
SINGLE_LINE_COMMENTS = [
'//', # C
'--', # Ada, Haskell, AppleScript
'#', # Ruby
'%', # Tex
'"', # Vim
]
# Start state on opening token, ignore anything until the closing
@@ -130,6 +132,9 @@ module Linguist
# extract_shebang("#!/usr/bin/env node")
# # => "node"
#
# extract_shebang("#!/usr/bin/env A=B foo=bar awk -f")
# # => "awk"
#
# Returns String token or nil it couldn't be parsed.
def extract_shebang(data)
s = StringScanner.new(data)
@@ -138,6 +143,7 @@ module Linguist
script = path.split('/').last
if script == 'env'
s.scan(/\s+/)
s.scan(/.*=[^\s]+\s+/)
script = s.scan(/\S+/)
end
script = script[/[^\d]+/, 0] if script