Saturday, November 26, 2011

Re: :make Success

* Paul <google01239@rainslide.net> [111126 18:27]:
> I want to do this, but only have the ls bit executed if make is successful:
>
> :make | !ls
>
> The help says that "when the command before the '|' generates an
> error, the following commands will not be executed". I see that
> ':make' is more or less like doing ':!make 2>&1 /tmp/something', which
> would always return successful because stderr is redirected to stdout.
> My aim is to have '!ls' (actually, any arbitrary shell command) only
> happen when make returned no errors in my file.
>
> Is it not possible, or perhaps I have to do something like
>
> :make | if empty(errorlist) | norm "!ls" | endif
>
> In which case, what would be the most efficient way of typing that?

Don't confuse :make with :!make. While internally, :make is going to
execute the OS's make command (assuming default 'makeprg'), the behavior
of | in this context depends on the result of the vim command :make, not
the result of the OS make. Apparently, the vim :make does not check the
return code of the OS make that it executes.

Perhaps this is a bug; I don't know if Bram will change it, though, as
it might have consequences to existing vim scripts using :make. Bram is
usually very cautious about making incompatible changes to
long-standing behavior, even when the existing behavior is clearly not
the best. And given that 'makeprg' does not always use make, there are
probably lots of scripts out there that assume :make will succeed even
if the executed 'makeprg' fails.

One possible solution would be to make the return code from the
'makeprg' available to vim script, perhaps in v:makerc. Then you could
use that in an :if condition.

...Marvin

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

Post a Comment