From 2517650ecb7e210211257ae262ca3c32932c218b Mon Sep 17 00:00:00 2001 From: Brandon Keepers Date: Fri, 28 Nov 2014 14:14:10 -0600 Subject: [PATCH] Fix shebang without path --- lib/linguist/shebang.rb | 2 +- test/test_shebang.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/linguist/shebang.rb b/lib/linguist/shebang.rb index 55481f69..4ed11412 100644 --- a/lib/linguist/shebang.rb +++ b/lib/linguist/shebang.rb @@ -21,7 +21,7 @@ module Linguist lines = data.lines return unless match = /^#! ?(.*)$/.match(lines.first) - tokens = match[0].split(' ') + tokens = match[1].split(' ') script = tokens.first.split('/').last script = tokens[1] if script == 'env' diff --git a/test/test_shebang.rb b/test/test_shebang.rb index aa3218f3..b359a771 100644 --- a/test/test_shebang.rb +++ b/test/test_shebang.rb @@ -32,6 +32,7 @@ class TestShebang < Test::Unit::TestCase assert_interpreter "python2", "#!/usr/bin/python2.7\n\n\n\n" assert_interpreter "python3", "#!/usr/bin/python3\n\n\n\n" assert_interpreter "sbcl", "#!/usr/bin/sbcl --script\n\n" + assert_interpreter "perl", "#! perl" end end