Skip to content

Commit

Permalink
Fix #749 - Use /bin/sh when the shell is fish
Browse files Browse the repository at this point in the history
  • Loading branch information
w0rp committed Jul 10, 2017
1 parent bd0f311 commit 30aef6b
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
12 changes: 9 additions & 3 deletions autoload/ale/job.vim
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,15 @@ function! ale#job#PrepareCommand(command) abort
" NeoVim handles this issue automatically if the command is a String,
" but we'll do this explicitly, so we use thes same exact command for both
" versions.
return has('win32')
\ ? 'cmd /c ' . a:command
\ : split(&shell) + split(&shellcmdflag) + [a:command]
if ale#Has('win32')
return 'cmd /c ' . a:command
endif

if &shell =~? 'fish$'
return ['/bin/sh', '-c', a:command]
endif

return split(&shell) + split(&shellcmdflag) + [a:command]
endfunction

" Start a job with options which are agnostic to Vim and NeoVim.
Expand Down
37 changes: 37 additions & 0 deletions test/test_prepare_command.vader
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Before:
Save &shell
Save &shellcmdflag

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 &shell = 'fish'

AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand('foobar')

let &shell = '/usr/bin/fish'

AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand('foobar')

let &shell = '/usr/local/bin/fish'

AssertEqual ['/bin/sh', '-c', 'foobar'], ale#job#PrepareCommand('foobar')

Execute(Other shells should be used when set):
let &shell = '/bin/bash'
let &shellcmdflag = '-c'

AssertEqual ['/bin/bash', '-c', 'foobar'], ale#job#PrepareCommand('foobar')

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}

AssertEqual 'cmd /c foobar', ale#job#PrepareCommand('foobar')

0 comments on commit 30aef6b

Please sign in to comment.