Fix #1115 - Add support for wrapping all commands with an option

This commit is contained in:
w0rp
2017-12-20 12:20:38 +00:00
parent 2495744fc3
commit e43e7065da
9 changed files with 148 additions and 30 deletions

View File

@@ -4,35 +4,36 @@ Before:
After:
Restore
let g:ale_has_override = {}
Execute(sh should be used when the shell is fish):
" Set something else, so we will replace that too.
let &shellcmdflag = '-f'
let g:ale_has_override = {'win32': 0}
if !has('win32')
" Set something else, so we will replace that too.
let &shellcmdflag = '-f'
let &shell = 'fish'
let &shell = 'fish'
AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar')
AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand('foobar')
let &shell = '/usr/bin/fish'
let &shell = '/usr/bin/fish'
AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar')
AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand('foobar')
let &shell = '/usr/local/bin/fish'
let &shell = '/usr/local/bin/fish'
AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand('foobar')
AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar')
endif
Execute(Other shells should be used when set):
let &shell = '/bin/bash'
let &shellcmdflag = '-c'
let g:ale_has_override = {'win32': 0}
if !has('win32')
let &shell = '/bin/bash'
let &shellcmdflag = '-c'
AssertEqual ['/bin/bash', '-c', 'foobar'], ale#job#PrepareCommand('foobar')
AssertEqual ['/bin/bash', '-c', 'foobar'], ale#job#PrepareCommand(bufnr(''), 'foobar')
endif
Execute(cmd /c as a string should be used on Windows):
let &shell = 'who cares'
let &shellcmdflag = 'whatever'
let g:ale_has_override = {'win32': 1}
if has('win32')
let &shell = 'who cares'
let &shellcmdflag = 'whatever'
AssertEqual 'cmd /c foobar', ale#job#PrepareCommand('foobar')
AssertEqual 'cmd /c foobar', ale#job#PrepareCommand(bufnr(''), 'foobar')
endif