The script's output is being used as a way to check for any syntax error,
it should print (and it is, in bash):
/bin/sh errors.sh
errors.sh: line 5: syntax error near unexpected token `newline'
errors.sh: line 5: `foo('
And yes, the job exits quickly, in fact, if you use a short sleep (ie:
sleep 1m) it works, not all the times, though.
I've been looking at the ch_logfile messages and got:
- RubJob # works
133.807009 : Starting job: /bin/sh errors.sh
133.807064 on 8: Created channel
133.807414 on 7: Freeing job
133.807501 : looking for messages on channels
133.807506 on 7: Closing channel
133.807508 on 7: Clearing channel
133.807511 on 7: Freeing channel
133.807534 : looking for messages on channels
133.808933 RECV on 8: 'errors.sh: line 5: syntax error near unexpected
token `newline'
errors.sh: line 5: `foo('
'
133.808941 on 8: Invoking channel callback HandlerCallback
133.809058 on 8: Invoking channel callback HandlerCallback
133.809108 ERR on 8: channel_select_check(): Cannot read from channel, will
close it soon
133.809112 : looking for messages on channels
133.809114 on 8: Closing channel because of previous read error
133.809116 on 8: Closing channel
133.809122 on 8: Invoking callbacks before closing
133.809124 on 8: Invoking close callback HandlerClose
134.309137 : looking for messages on channels
144.312764 on 8: Job ended
- RunJob | sleep 50m # doesn't work
151.694974 : Starting job: /bin/sh errors.sh
151.695013 on 9: Created channel
151.695387 on 8: Freeing job
151.745598 ERR on 9: channel_select_check(): Cannot read from channel, will
close it soon
151.745623 : looking for messages on channels
151.745628 on 9: Closing channel because of previous read error
151.745631 on 9: Closing channel
151.745650 on 9: Invoking callbacks before closing
151.745655 on 9: Invoking close callback HandlerClose
151.745764 on 8: Closing channel
151.745767 on 8: Clearing channel
151.745771 on 8: Freeing channel
151.745792 : looking for messages on channels
162.255837 on 9: Job ended
On Tue, Sep 13, 2016 at 4:59 PM, Bram Moolenaar <[email protected]> wrote:
>
> 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 -- [email protected] -- 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
> ///
>
--
Santiago Alejandro Agüero
[email protected]
--
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.