@@ -96,11 +96,16 @@ function! s:execute(command, options) abort
9696
9797 let job_id = -1
9898 if s: is_nvim
99- let options = {
100- \ ' on_stdout' : function (' s:_inner_out_cb' , [a: options .out_cb]),
101- \ ' on_stderr' : function (' s:_inner_err_cb' , [a: options .err_cb]),
102- \ ' on_exit' : function (' s:_inner_exit_cb' , [a: options .exit_cb]),
103- \ }
99+ let options = {}
100+ if has_key (a: options , ' out_cb' )
101+ let options [' on_stdout' ] = function (' s:_inner_out_cb' , [a: options .out_cb])
102+ endif
103+ if has_key (a: options , ' err_cb' )
104+ let options [' on_stderr' ] = function (' s:_inner_err_cb' , [a: options .err_cb])
105+ endif
106+ if has_key (a: options , ' exit_cb' )
107+ let options [' on_exit' ] = function (' s:_inner_exit_cb' , [a: options .exit_cb])
108+ endif
104109
105110 let job_id = jobstart ([&shell ] + args , options )
106111
@@ -114,11 +119,16 @@ function! s:execute(command, options) abort
114119 \ ' stop' : function (' jobstop' , [job_id]),
115120 \ }
116121 else
117- let options = {
118- \ ' out_cb' : function (' s:_inner_out_cb' , [a: options .out_cb]),
119- \ ' err_cb' : function (' s:_inner_err_cb' , [a: options .err_cb]),
120- \ ' exit_cb' : function (' s:_inner_exit_cb' , [a: options .exit_cb]),
121- \ }
122+ let options = {}
123+ if has_key (a: options , ' out_cb' )
124+ let options [' out_cb' ] = function (' s:_inner_out_cb' , [a: options .out_cb])
125+ endif
126+ if has_key (a: options , ' err_cb' )
127+ let options [' err_cb' ] = function (' s:_inner_err_cb' , [a: options .err_cb])
128+ endif
129+ if has_key (a: options , ' exit_cb' )
130+ let options [' exit_cb' ] = function (' s:_inner_exit_cb' , [a: options .exit_cb])
131+ endif
122132
123133 let job = job_start ([&shell ] + args , options )
124134
0 commit comments