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?
There is v:shell_error
variable that has exactly the same value as $?
in shell scripts. Works at least after :!
, :read !
, calling system()
.
its like this
var=$(echo $?)
will give you the value of $? into the variable var. The standard output of course is obtained. because, only after the output is worked, the return value is obtained. ($? comes either as 0 or 1 only after executing the command).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.