From eec8b9da60092bd9f88a8b56bee698e251dfc2de Mon Sep 17 00:00:00 2001 From: Andrew Imeson Date: Thu, 24 Jan 2019 13:30:50 -0500 Subject: [PATCH 1/2] Fix test name for csh to not say zsh --- test/test_shell_detection.vader | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_shell_detection.vader b/test/test_shell_detection.vader index adb8d70d..1b0a20e3 100644 --- a/test/test_shell_detection.vader +++ b/test/test_shell_detection.vader @@ -52,7 +52,7 @@ Execute(zsh should be detected appropriately): Given(A file with a csh hash bang and arguments): #!/usr/bin/env csh -eu --foobar -Execute(zsh should be detected appropriately): +Execute(csh should be detected appropriately): AssertEqual 'csh', ale#handlers#sh#GetShellType(bufnr('')) AssertEqual 'csh', ale_linters#sh#shell#GetExecutable(bufnr('')) AssertEqual 'csh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr('')) From a6de3f37274d4db9774136350d6475397dc7ac21 Mon Sep 17 00:00:00 2001 From: Andrew Imeson Date: Thu, 24 Jan 2019 13:49:16 -0500 Subject: [PATCH 2/2] Add better detection for KornShell/ksh --- autoload/ale/handlers/sh.vim | 2 +- test/test_shell_detection.vader | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/autoload/ale/handlers/sh.vim b/autoload/ale/handlers/sh.vim index e96dd3ce..75eaf71f 100644 --- a/autoload/ale/handlers/sh.vim +++ b/autoload/ale/handlers/sh.vim @@ -9,7 +9,7 @@ function! ale#handlers#sh#GetShellType(buffer) abort " Remove options like -e, etc. let l:command = substitute(l:bang_line, ' --\?[a-zA-Z0-9]\+', '', 'g') - for l:possible_shell in ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'sh'] + for l:possible_shell in ['bash', 'dash', 'ash', 'tcsh', 'csh', 'zsh', 'ksh', 'sh'] if l:command =~# l:possible_shell . '\s*$' return l:possible_shell endif diff --git a/test/test_shell_detection.vader b/test/test_shell_detection.vader index 1b0a20e3..88ee462d 100644 --- a/test/test_shell_detection.vader +++ b/test/test_shell_detection.vader @@ -57,6 +57,22 @@ Execute(csh should be detected appropriately): AssertEqual 'csh', ale_linters#sh#shell#GetExecutable(bufnr('')) AssertEqual 'csh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr('')) +Given(A file with a ksh hashbang): + #!/bin/ksh + +Execute(/bin/ksh should be detected appropriately): + AssertEqual 'ksh', ale#handlers#sh#GetShellType(bufnr('')) + AssertEqual 'ksh', ale_linters#sh#shell#GetExecutable(bufnr('')) + AssertEqual 'ksh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr('')) + +Given(A file with a ksh as an argument to env): + #!/usr/bin/env ksh + +Execute(ksh should be detected appropriately): + AssertEqual 'ksh', ale#handlers#sh#GetShellType(bufnr('')) + AssertEqual 'ksh', ale_linters#sh#shell#GetExecutable(bufnr('')) + AssertEqual 'ksh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr('')) + Given(A file with a sh hash bang and arguments): #!/usr/bin/env sh -eu --foobar