Bram,
I maintain the popular eye-candy plugin vim-airline. For files
maintained in git, it checks the current branch and displays it in the
statusline using system('git status...') and caches the result, so that
it is not called to often. However after a ShellCmdPost autocommand, it
invalidates the cache and runs the command to update it (since the user
could have interacted with git using !git..)
However, calling system() after the ShellCmdPost means, that it will
overwrite v:shell_error and that means, that a user cannot check the
result properly, e.g. executing :! false followed by echo v:shell_error
will return 0 instead of 1 as expected.
Therefore, could we please make v:shell_error writable, so that the
plugin can save and restore the old value and not interact with the
return code of a shell command as expected?
Attached is a patch, that would allow that. Please include.
PS: I know, I could use async to work-around it...
Best,
Christian
--
--
You received this message from the "vim_dev" 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
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 43d1883..361f153 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -1828,7 +1828,7 @@ v:shell_error Result of the last shell command. When non-zero, the last
shell command had an error. When zero, there was no problem.
This only works when the shell returns the error code to Vim.
The value -1 is often used when the command could not be
- executed. Read-only.
+ executed. Read-write.
Example: >
:!mv foo bar
:if v:shell_error
diff --git a/src/eval.c b/src/eval.c
index 3b5abe9..91db530 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -112,7 +112,7 @@ static struct vimvar
{VV_NAME("errmsg", VAR_STRING), VV_COMPAT},
{VV_NAME("warningmsg", VAR_STRING), 0},
{VV_NAME("statusmsg", VAR_STRING), 0},
- {VV_NAME("shell_error", VAR_NUMBER), VV_COMPAT+VV_RO},
+ {VV_NAME("shell_error", VAR_NUMBER), VV_COMPAT},
{VV_NAME("this_session", VAR_STRING), VV_COMPAT},
{VV_NAME("version", VAR_NUMBER), VV_COMPAT+VV_RO},
{VV_NAME("lnum", VAR_NUMBER), VV_RO_SBX},