#69 Improve shell detection

This commit is contained in:
w0rp 2016-10-09 19:32:01 +01:00
parent 34241edcdb
commit 9d52d968db

View File

@ -14,20 +14,18 @@ if !exists('g:ale_linters_sh_shell_default_shell')
endif endif
function! ale_linters#sh#shell#GetExecutable(buffer) function! ale_linters#sh#shell#GetExecutable(buffer)
let shell = g:ale_linters_sh_shell_default_shell
let banglines = getbufline(a:buffer, 1) let banglines = getbufline(a:buffer, 1)
" Take the shell executable from the hashbang, if we can. " Take the shell executable from the hashbang, if we can.
if len(banglines) == 1 if len(banglines) == 1 && banglines[0] =~# '^#!'
let bangmatch = matchlist(banglines[0], '^#!\([^ ]\+\)') for possible_shell in ['bash', 'tcsh', 'csh', 'zsh', 'sh']
if banglines[0] =~# possible_shell . '\s*$'
if len(bangmatch) > 0 return possible_shell
let shell = bangmatch[1] endif
endif endfor
endif endif
return shell return g:ale_linters_sh_shell_default_shell
endfunction endfunction
function! ale_linters#sh#shell#GetCommand(buffer) function! ale_linters#sh#shell#GetCommand(buffer)