Capturing the exit status of 'makeprg'

13 views
Skip to first unread message

Gary Johnson

unread,
Nov 29, 2016, 7:56:41 PM11/29/16
to vim...@googlegroups.com
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

Reply all
Reply to author
Forward
0 new messages