Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get return (status) value of an external command in Vim

Tags:

linux

shell

vim

I want to get the exit value (returned by $? on a shell; usually 0 or 1 for success or failure) of a external shell command in Vim. Note that I want to get its standard output too. So I can use the output and the also the exit value in a Vim conditional expression. Is this possible?

like image 962
highsciguy Avatar asked Mar 22 '12 18:03

highsciguy


1 Answers

There is v:shell_error variable that has exactly the same value as $? in shell scripts. Works at least after :!, :read !, calling system().

like image 147
ZyX Avatar answered Oct 28 '22 04:10

ZyX