All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Author: w0rp <devw0rp@gmail.com>
2 " Description: Lints shell files by invoking the shell with -n
4 " This option can be changed to change the default shell when the shell
5 " cannot be taken from the hashbang line.
6 if !exists('g:ale_sh_shell_default_shell')
7 let g:ale_sh_shell_default_shell = fnamemodify($SHELL, ':t')
9 if g:ale_sh_shell_default_shell is# '' || g:ale_sh_shell_default_shell is# 'fish'
10 let g:ale_sh_shell_default_shell = 'bash'
14 function! ale_linters#sh#shell#GetExecutable(buffer) abort
15 let l:shell_type = ale#handlers#sh#GetShellType(a:buffer)
17 if !empty(l:shell_type)
21 return ale#Var(a:buffer, 'sh_shell_default_shell')
24 function! ale_linters#sh#shell#GetCommand(buffer) abort
25 return ale_linters#sh#shell#GetExecutable(a:buffer) . ' -n %t'
28 function! ale_linters#sh#shell#Handle(buffer, lines) abort
29 " Matches patterns line the following:
31 " bash: line 13: syntax error near unexpected token `d'
32 " bash:行0: 未预期的符号“done”附近有语法错误
33 " bash: 列 90: 尋找匹配的「"」時遇到了未預期的檔案結束符
34 " sh: 11: Syntax error: "(" unexpected
35 let l:pattern = '\v([^:]+:\D*)(\d+): (.+)$'
38 for l:match in ale#util#GetMatches(a:lines, l:pattern)
40 \ 'lnum': str2nr(l:match[2]),
48 call ale#linter#Define('sh', {
50 \ 'output_stream': 'stderr',
51 \ 'executable': function('ale_linters#sh#shell#GetExecutable'),
52 \ 'command': function('ale_linters#sh#shell#GetCommand'),
53 \ 'callback': 'ale_linters#sh#shell#Handle',