Add better detection for KornShell/ksh

This commit is contained in:
Andrew Imeson 2019-01-24 13:49:16 -05:00
parent eec8b9da60
commit a6de3f3727
No known key found for this signature in database
GPG Key ID: 82A3DCD89FC9E016
2 changed files with 17 additions and 1 deletions

View File

@ -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

View File

@ -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