I’m trying to get the “0 of success, nonzero if error” return code from make in Vim. Specifically, I am on Ubuntu and using v:shell_error does not work.
After digging around and looking at this question, it seems to be because of my shellpipe setting, which is
shellpipe=2>&1| tee
The tee pipes the make output back into vim. The shell is apparently returning the error code from tee to vim and not from make. How do I get make’s error code instead?
You can try to make a custom function for that. E.g. using
:call system("make > make.out")run make redirecting output into a file. After that load the error file using:cf make.out. Never tried that myself, though.In the end, results of
makemight be also simply checked by testing whether the result is there, in the file system:(Here the ‘|’ symbol is vim’s command separator.) Assigning that to a keyboard shortcut would remove the need for typing.
P.S. I usually try to make my programs to produce no warnings, so I never really came across the issue. What BTW leads to another possible solution: simply remove warnings (or simply undesired output lines) using e.g.
grep -v taboowordfrom the make output by overriding the'makeprg'. What is actually described in the help::h 'makeprg'.P.P.S. I got started on the VIM… Provided that you also use bash as a shell. Did you tried to add to the exit ${PIPESTATUS[0]} to the shellpipe? E.g.:
Just tested that on Debian and it worked for me.
:h 'shellpipe'for more.