Fix 🐛 on file starting with single shebang

This commit is contained in:
Alexander Bezzubov
2017-07-25 10:25:43 +02:00
parent 7cd8904cbb
commit 3303cf7824
2 changed files with 5 additions and 2 deletions

View File

@ -284,14 +284,16 @@ func getInterpreter(data []byte) (interpreter string) {
// skip shebang
line = bytes.TrimSpace(line[2:])
splitted := bytes.Fields(line)
if len(splitted) == 0 {
return ""
}
if bytes.Contains(splitted[0], []byte("env")) {
if len(splitted) > 1 {
interpreter = string(splitted[1])
}
} else {
splittedPath := bytes.Split(splitted[0], []byte{'/'})
interpreter = string(splittedPath[len(splittedPath)-1])
}