2017-08-28 18:16:23 +00:00
|
|
|
Before:
|
|
|
|
runtime ale_linters/sh/shell.vim
|
|
|
|
runtime ale_linters/sh/shellcheck.vim
|
|
|
|
|
|
|
|
After:
|
|
|
|
call ale#linter#Reset()
|
|
|
|
|
|
|
|
unlet! b:is_bash
|
|
|
|
unlet! b:is_sh
|
|
|
|
unlet! b:is_kornshell
|
|
|
|
|
|
|
|
Given(A file with a Bash hashbang):
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
Execute(/bin/bash should be detected appropriately):
|
|
|
|
AssertEqual 'bash', ale#handlers#sh#GetShellType(bufnr(''))
|
|
|
|
AssertEqual 'bash', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
|
|
|
AssertEqual 'bash', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
|
|
|
|
|
|
|
Given(A file with /bin/sh):
|
|
|
|
#!/usr/bin/env sh -eu --foobar
|
|
|
|
|
|
|
|
Execute(/bin/sh should be detected appropriately):
|
|
|
|
AssertEqual 'sh', ale#handlers#sh#GetShellType(bufnr(''))
|
|
|
|
AssertEqual 'sh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
|
|
|
AssertEqual 'sh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
|
|
|
|
|
|
|
Given(A file with bash as an argument to env):
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
Execute(/usr/bin/env bash should be detected appropriately):
|
|
|
|
AssertEqual 'bash', ale#handlers#sh#GetShellType(bufnr(''))
|
|
|
|
AssertEqual 'bash', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
|
|
|
AssertEqual 'bash', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
|
|
|
|
|
|
|
Given(A file with a tcsh hash bang and arguments):
|
|
|
|
#!/usr/bin/env tcsh -eu --foobar
|
|
|
|
|
|
|
|
Execute(tcsh should be detected appropriately):
|
|
|
|
AssertEqual 'tcsh', ale#handlers#sh#GetShellType(bufnr(''))
|
|
|
|
AssertEqual 'tcsh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
|
|
|
AssertEqual 'tcsh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
|
|
|
|
|
|
|
Given(A file with a zsh hash bang and arguments):
|
|
|
|
#!/usr/bin/env zsh -eu --foobar
|
|
|
|
|
|
|
|
Execute(zsh should be detected appropriately):
|
|
|
|
AssertEqual 'zsh', ale#handlers#sh#GetShellType(bufnr(''))
|
|
|
|
AssertEqual 'zsh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
|
|
|
AssertEqual 'zsh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
|
|
|
|
|
|
|
Given(A file with a csh hash bang and arguments):
|
|
|
|
#!/usr/bin/env csh -eu --foobar
|
|
|
|
|
2019-01-24 18:30:50 +00:00
|
|
|
Execute(csh should be detected appropriately):
|
2017-08-28 18:16:23 +00:00
|
|
|
AssertEqual 'csh', ale#handlers#sh#GetShellType(bufnr(''))
|
|
|
|
AssertEqual 'csh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
|
|
|
AssertEqual 'csh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
|
|
|
|
2019-01-24 18:49:16 +00:00
|
|
|
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(''))
|
|
|
|
|
2017-08-28 18:16:23 +00:00
|
|
|
Given(A file with a sh hash bang and arguments):
|
|
|
|
#!/usr/bin/env sh -eu --foobar
|
|
|
|
|
|
|
|
Execute(sh should be detected appropriately):
|
|
|
|
AssertEqual 'sh', ale#handlers#sh#GetShellType(bufnr(''))
|
|
|
|
AssertEqual 'sh', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
|
|
|
AssertEqual 'sh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
|
|
|
|
|
|
|
Given(A file without a hashbang):
|
|
|
|
|
|
|
|
Execute(The bash dialect should be used for shellcheck if b:is_bash is 1):
|
|
|
|
let b:is_bash = 1
|
|
|
|
|
|
|
|
AssertEqual 'bash', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The sh dialect should be used for shellcheck if b:is_sh is 1):
|
|
|
|
let b:is_sh = 1
|
|
|
|
|
|
|
|
AssertEqual 'sh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
|
|
|
|
|
|
|
Execute(The ksh dialect should be used for shellcheck if b:is_kornshell is 1):
|
|
|
|
let b:is_kornshell = 1
|
|
|
|
|
|
|
|
AssertEqual 'ksh', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
2017-10-26 20:17:47 +00:00
|
|
|
|
|
|
|
Given(A file with /bin/ash):
|
|
|
|
#!/bin/ash
|
|
|
|
|
|
|
|
Execute(The ash dialect should be used for the shell and the base function):
|
|
|
|
AssertEqual 'ash', ale#handlers#sh#GetShellType(bufnr(''))
|
|
|
|
AssertEqual 'ash', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
|
|
|
|
|
|
|
Execute(dash should be used for shellcheck, which has no ash dialect):
|
|
|
|
AssertEqual 'dash', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|
|
|
|
|
|
|
|
Given(A file with /bin/dash):
|
|
|
|
#!/bin/dash
|
|
|
|
|
|
|
|
Execute(The dash dialect should be used for the shell and the base function):
|
|
|
|
AssertEqual 'dash', ale#handlers#sh#GetShellType(bufnr(''))
|
|
|
|
AssertEqual 'dash', ale_linters#sh#shell#GetExecutable(bufnr(''))
|
|
|
|
|
|
|
|
Execute(dash should be used for shellcheck):
|
|
|
|
AssertEqual 'dash', ale_linters#sh#shellcheck#GetDialectArgument(bufnr(''))
|