diff options
author | w0rp <devw0rp@gmail.com> | 2016-10-09 21:04:43 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2016-10-09 21:04:43 +0100 |
commit | a1ecf9eceaf2b80738c37792dc73961522cc0cde (patch) | |
tree | f5ee5819d81ff8df63e048f3806d17e67aff937a /ale_linters | |
parent | dea8af1e5706cbed01547d71c955caf94dae7515 (diff) | |
parent | 07599d006ca35fe5272fd0d5decb25d18e3086a8 (diff) | |
download | ale-a1ecf9eceaf2b80738c37792dc73961522cc0cde.zip |
Merge branch 'shell-detection'
Diffstat (limited to 'ale_linters')
-rw-r--r-- | ale_linters/sh/shell.vim | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/ale_linters/sh/shell.vim b/ale_linters/sh/shell.vim index 2ea253df..07c5650c 100644 --- a/ale_linters/sh/shell.vim +++ b/ale_linters/sh/shell.vim @@ -10,24 +10,29 @@ let g:loaded_ale_linters_sh_shell = 1 " This option can be changed to change the default shell when the shell " cannot be taken from the hashbang line. if !exists('g:ale_linters_sh_shell_default_shell') - let g:ale_linters_sh_shell_default_shell = 'bash' + let g:ale_linters_sh_shell_default_shell = fnamemodify($SHELL, ':t') + + if g:ale_linters_sh_shell_default_shell ==# '' + let g:ale_linters_sh_shell_default_shell = 'bash' + endif endif function! ale_linters#sh#shell#GetExecutable(buffer) - let shell = g:ale_linters_sh_shell_default_shell - let banglines = getbufline(a:buffer, 1) " Take the shell executable from the hashbang, if we can. - if len(banglines) == 1 - let bangmatch = matchlist(banglines[0], '^#!\([^ ]\+\)') - - if len(bangmatch) > 0 - let shell = bangmatch[1] - endif + if len(banglines) == 1 && banglines[0] =~# '^#!' + " Remove options like -e, etc. + let line = substitute(banglines[0], '--\?[a-zA-Z0-9]\+', '', 'g') + + for possible_shell in ['bash', 'tcsh', 'csh', 'zsh', 'sh'] + if line =~# possible_shell . '\s*$' + return possible_shell + endif + endfor endif - return shell + return g:ale_linters_sh_shell_default_shell endfunction function! ale_linters#sh#shell#GetCommand(buffer) |