mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-07 21:24:33 +08:00
ShellDetect: fall back to filetype if no hashbang
Some files lack a hashbang line but still have an unambiguous filetype. For example, the file `.zshrc` has the filetype `zsh`. Augment ale#handlers#sh#GetShellType to fall back to the filetype if no hashbang line can be found.
This commit is contained in:
@@ -98,6 +98,16 @@ Execute(The ksh dialect should be used for shellcheck if b:is_kornshell is 1):
|
||||
|
||||
AssertEqual 'ksh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
||||
|
||||
Execute(The filetype should be used as the default shell type when there is no hashbang line):
|
||||
set filetype=zsh
|
||||
AssertEqual 'zsh', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
|
||||
set filetype=tcsh
|
||||
AssertEqual 'tcsh', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
|
||||
set filetype=python
|
||||
AssertEqual '', ale#handlers#sh#GetShellType(bufnr(''))
|
||||
|
||||
Given(A file with /bin/ash):
|
||||
#!/bin/ash
|
||||
|
||||
|
||||
Reference in New Issue
Block a user