Tuesday, November 29, 2016

Capturing the exit status of 'makeprg'

I was working on a plugin in which I wanted to capture the exit
status of my 'makeprg', preferably using v:shell_error. The trouble
was that on Unix, 'shellpipe' is "2>&1| tee", so that following
:make, v:shell_error contained the exit status of tee and not of
'makeprg'.

I solved the problem by using bash's PIPESTATUS array variable to
access the exit status of the first command in the :make pipeline
and modifying 'shellpipe' to exit with that status.

let l:save_sp = &shellpipe
let &shellpipe .= " %s; exit ${PIPESTATUS[0]}"
make
" v:shell_error now contains the exit status of 'makeprg'.
let &shellpipe = l:save_sp

Let me know if there's a better way to do that. In the meantime,
I hope someone finds that useful.

Regards,
Gary

--
--
You received this message from the "vim_use" 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_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment