#869 - Detect the shell dialect from the hashbang for shellcheck

This commit is contained in:
w0rp
2017-08-28 19:16:23 +01:00
parent 73ec83d055
commit b031531e79
5 changed files with 173 additions and 21 deletions

View File

@@ -17,18 +17,10 @@ if !exists('g:ale_sh_shell_default_shell')
endif
function! ale_linters#sh#shell#GetExecutable(buffer) abort
let l:banglines = getbufline(a:buffer, 1)
let l:shell_type = ale#handlers#sh#GetShellType(a:buffer)
" Take the shell executable from the hashbang, if we can.
if len(l:banglines) == 1 && l:banglines[0] =~# '^#!'
" Remove options like -e, etc.
let l:line = substitute(l:banglines[0], '--\?[a-zA-Z0-9]\+', '', 'g')
for l:possible_shell in ['bash', 'tcsh', 'csh', 'zsh', 'sh']
if l:line =~# l:possible_shell . '\s*$'
return l:possible_shell
endif
endfor
if !empty(l:shell_type)
return l:shell_type
endif
return ale#Var(a:buffer, 'sh_shell_default_shell')