From 30aef6b19a7d0ac713b3d7ca99f225d8dd8187f5 Mon Sep 17 00:00:00 2001 From: w0rp Date: Mon, 10 Jul 2017 21:35:35 +0100 Subject: [PATCH] Fix #749 - Use /bin/sh when the shell is fish --- autoload/ale/job.vim | 12 ++++++++--- test/test_prepare_command.vader | 37 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 test/test_prepare_command.vader diff --git a/autoload/ale/job.vim b/autoload/ale/job.vim index b9ab86b7..93f28824 100644 --- a/autoload/ale/job.vim +++ b/autoload/ale/job.vim @@ -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. diff --git a/test/test_prepare_command.vader b/test/test_prepare_command.vader new file mode 100644 index 00000000..5707be72 --- /dev/null +++ b/test/test_prepare_command.vader @@ -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')