Santiago Alejandro Agüero wrote: > While I was trying to write some vim code for testing a (async) > functionality for Neomake plugin, I've noticed the following scenario: > > > - Having the following shell script (with errors): > > #!/bin/sh > > a='$var' > > foo( > > > - And the next vim test code: > > function! StartJob() > let g:job = job_start(['/bin/sh', 'errors.sh'], { > \ 'callback': 'HandlerCallback', > \ 'close_cb': 'HandlerClose', > \ 'exit_cb': 'HandlerExit' > \ }) > endfunction > > function! HandlerCallback(channel, line) abort > call Debug('[Callback] channel: ' . a:channel . ', line: ' . a:line . ', > channelStatus: ' . ch_status(a:channel)) > endfunction > > function! HandlerClose(channel) abort > call Debug('[Close] channel: ' . a:channel . ', channelStatus: ' . > ch_status(a:channel)) > endfunction > > function! HandlerExit(job, status) abort > call Debug('[Exit] job: ' . a:job . ', status: ' . a:status . ', > jobStatus: ' . job_status(a:job)) > endfunction > > function! Debug(msg) abort > call writefile([a:msg], 'output.log', 'a') > endfunction > > command! -bar RunJob call StartJob() > > > - Then the following thing happens: > > - RunJob # Works OK, both HandlerCallback (with data) and HandlerClose are > called
What data is received? The shell script doesn't write anything. > - RunJob | sleep 50m # Does not work, only HandlerClose and HandlerExit are > being called (no buffered data) > > > The reason I need the sleep is that I want to check every 50m for the > job_status in order to continue with some test assertions. > > Also, I've noticed that this does not happen with other commands... Is there > something special about /bin/sh? This might be related to a problem that was reported but I could not reproduce: When the job exits quickly, Vim doesn't read the output, because the channel handle gets an error before reading. You should be able to get more information with ch_logfile(). -- hundred-and-one symptoms of being an internet addict: 269. You wonder how you can make your dustbin produce Sesame Street's Oscar's the Garbage Monster song when you empty it. /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org /// -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.