mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Handle empty shebang with whitespace
This commit is contained in:
@@ -19,11 +19,12 @@ module Linguist
|
|||||||
# Returns a String or nil
|
# Returns a String or nil
|
||||||
def self.interpreter(data)
|
def self.interpreter(data)
|
||||||
lines = data.lines
|
lines = data.lines
|
||||||
return unless match = /^#! ?(.+)$/.match(lines.first)
|
|
||||||
|
|
||||||
tokens = match[1].split(' ')
|
return unless match = /^#!(.+)$/.match(lines.first)
|
||||||
script = tokens.first.split('/').last
|
|
||||||
|
|
||||||
|
tokens = match[1].strip.split(' ')
|
||||||
|
return if tokens.empty?
|
||||||
|
script = File.basename(tokens.first)
|
||||||
script = tokens[1] if script == 'env'
|
script = tokens[1] if script == 'env'
|
||||||
|
|
||||||
# If script has an invalid shebang, we might get here
|
# If script has an invalid shebang, we might get here
|
||||||
|
|||||||
Reference in New Issue
Block a user