Friday, July 6, 2012

Re: exit code when running running vim scripts

On Sat, Jul 7, 2012 at 12:46 AM, Aaron Bohannon <aaron678@gmail.com> wrote:
> Hi,
>
> I wanted to install a vimball without actually starting vim. So I tried this:
>
> ex -NsS my_vimball.vmb -c q
>
> It seems to work perfectly, except that I get an exit code of 1. I'm
> just curious why that is. Any ideas?
>
> On the other hand, it seems that this version gives me an exit code of 0:
>
> vim -S my_vimball.vmb -c q
>
> So I'm not too worried about the non-zero exit code issue. I'm just curious.

In Ex mode, any error message causes to set exit code non-zero.
According to source code comment, this is for POSIX compliant.
To exit with 0, use :visual command before :quit.

main.c:getout()
/* When running in Ex mode an error causes us to exit with a non-zero exit
* code. POSIX requires this, although it's not 100% clear from the
* standard. */
if (exmode_active)
exitval += ex_exitval;

--
Yukihiro Nakadaira - yukihiro.nakadaira@gmail.com

--
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

No comments: