From 1997a8f7e22a930e3d47b61a7f9ab948d04f2b92 Mon Sep 17 00:00:00 2001 From: Eddie Lebow Date: Sat, 23 Nov 2019 00:06:03 -0500 Subject: 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. --- test/test_shell_detection.vader | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test') diff --git a/test/test_shell_detection.vader b/test/test_shell_detection.vader index 88ee462d..b0b38aad 100644 --- a/test/test_shell_detection.vader +++ b/test/test_shell_detection.vader @@ -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 -- cgit v1.2.3