diff options
author | w0rp <devw0rp@gmail.com> | 2017-08-28 19:16:23 +0100 |
---|---|---|
committer | w0rp <devw0rp@gmail.com> | 2017-08-28 19:16:23 +0100 |
commit | b031531e79d409af3b143a1f40431cd868cd78fb (patch) | |
tree | 43109aa362992890041ec486fdc2f64bdb14325d /autoload | |
parent | 73ec83d055a62019c41e699981e841e395219cca (diff) | |
download | ale-b031531e79d409af3b143a1f40431cd868cd78fb.zip |
#869 - Detect the shell dialect from the hashbang for shellcheck
Diffstat (limited to 'autoload')
-rw-r--r-- | autoload/ale/handlers/sh.vim | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/autoload/ale/handlers/sh.vim b/autoload/ale/handlers/sh.vim new file mode 100644 index 00000000..894879ee --- /dev/null +++ b/autoload/ale/handlers/sh.vim @@ -0,0 +1,20 @@ +" Author: w0rp <devw0rp@gmail.com> + +" Get the shell type for a buffer, based on the hashbang line. +function! ale#handlers#sh#GetShellType(buffer) abort + let l:bang_line = get(getbufline(a:buffer, 1), 0, '') + + " Take the shell executable from the hashbang, if we can. + if l:bang_line[:1] is# '#!' + " Remove options like -e, etc. + let l:command = substitute(l:bang_line, ' --\?[a-zA-Z0-9]\+', '', 'g') + + for l:possible_shell in ['bash', 'tcsh', 'csh', 'zsh', 'sh'] + if l:command =~# l:possible_shell . '\s*$' + return l:possible_shell + endif + endfor + endif + + return '' +endfunction |