Skip to content

Commit 131f850

Browse files
authored
Merge pull request #846 from mikoto2000/delete-shell-in-asyncprocess
2 parents c4e7796 + c8f7e92 commit 131f850

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

autoload/vital/__vital__/System/AsyncProcess.vim

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ if !s:is_nvim
3636
endfunction
3737

3838
function! s:_inner_err_cb(user_err_cb, ch, msg) abort
39-
call a:user_err_cb(s:_ensure_buffer_string(result))
39+
call a:user_err_cb(s:_ensure_buffer_string(a:msg))
4040
endfunction
4141
else
4242
" inner callbacks for Neovim
@@ -83,17 +83,6 @@ function! s:execute(command, options) abort
8383
throw 'vital: AsyncProcess: invalid argument (value type:' . type(a:command) . ')'
8484
endif
8585

86-
" build args
87-
let args = []
88-
if stridx(&shell, 'cmd.exe') != -1
89-
" cmd.exe
90-
let args = args + ['/c']
91-
else
92-
" sh, bash, pwsh, etc.
93-
let args = args + ['-c']
94-
endif
95-
let args = args + [command]
96-
9786
let job_id = -1
9887
if s:is_nvim
9988
let options = {}
@@ -107,7 +96,7 @@ function! s:execute(command, options) abort
10796
let options['on_exit'] = function('s:_inner_exit_cb', [a:options.exit_cb])
10897
endif
10998

110-
let job_id = jobstart([&shell] + args, options)
99+
let job_id = jobstart(command, options)
111100

112101
if has_key(a:options, 'timeout')
113102
if a:options.timeout > 0
@@ -130,7 +119,7 @@ function! s:execute(command, options) abort
130119
let options['exit_cb'] = function('s:_inner_exit_cb', [a:options.exit_cb])
131120
endif
132121

133-
let job = job_start([&shell] + args, options)
122+
let job = job_start(command, options)
134123

135124
if has_key(a:options, 'timeout')
136125
if a:options.timeout > 0

test/System/AsyncProcess.vimspec

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ Describe System.AsyncProcess
4747
let g:exit_code = a:exit_code
4848
endfunction
4949

50-
let args = 'echo "abcdefg"'
50+
if s:is_windows
51+
let args = 'cmd.exe /c echo "abcdefg"'
52+
else
53+
let args = 'bash -c "echo \"abcdefg\""'
54+
endif
55+
5156
call AsyncProcess.execute(args, {
5257
\ 'exit_cb': function('s:my_exit_cb'),
5358
\ 'out_cb': function('s:my_out_cb'),
@@ -60,7 +65,7 @@ Describe System.AsyncProcess
6065
Assert Equals(g:err_msg, "")
6166

6267
if s:is_windows
63-
let actual_out_msg = '\"abcdefg\"'
68+
let actual_out_msg = '"abcdefg"'
6469
else
6570
let actual_out_msg = "abcdefg"
6671
endif

0 commit comments

Comments
 (0)