Skip to content

Commit e0a301a

Browse files
committed
Provide v:shell_error equivalent (g:xolox#shell#make_exit_code)
See issue #8 on GitHub: #8
1 parent f8ee02d commit e0a301a

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Note that on UNIX if the environment variable `$DISPLAY` is empty the plug-in wi
4040

4141
This command is a very simple replacement for the [:make][make] command that does not pop up a console window on Windows. It doesn't come with all of the bells and whistles that Vim's built-in make command does but it should work.
4242

43+
Because Vim's [v:shell_error][shell_error] variable is read only (which means it cannot be set by a Vim plug-in) the vim-shell plug-in defines its own variable with the exit code of the `make` process executed by `:MakeWithShell`. This variable is called `g:xolox#shell#make_exit_code`. The semantics are exactly the same as for [v:shell_error][shell_error].
44+
4345
### The `xolox#misc#os#exec()` function
4446

4547
This function enables other Vim plug-ins to execute external commands in the background (i.e. asynchronously) *without opening a command prompt window on Windows*. For example try to execute the following command on Windows ([vimrun.exe][vimrun] is only included with Vim for Windows because it isn't needed on other platforms):
@@ -135,6 +137,7 @@ This software is licensed under the [MIT license](http://en.wikipedia.org/wiki/M
135137
[make]: http://vimdoc.sourceforge.net/htmldoc/quickfix.html#:make
136138
[sh_opt]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27shell%27
137139
[shcf_opt]: http://vimdoc.sourceforge.net/htmldoc/options.html#%27shellcmdflag%27
140+
[shell_error]: http://vimdoc.sourceforge.net/htmldoc/eval.html#v:shell_error
138141
[system]: http://vimdoc.sourceforge.net/htmldoc/eval.html#system()
139142
[vim]: http://www.vim.org/
140143
[vim_scripts_entry]: http://www.vim.org/scripts/script.php?script_id=3123

autoload/xolox/shell.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim auto-load script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: May 13, 2013
3+
" Last Change: May 14, 2013
44
" URL: http://peterodding.com/code/vim/shell/
55

6-
let g:xolox#shell#version = '0.12.1'
6+
let g:xolox#shell#version = '0.12.2'
77

88
call xolox#misc#compat#check('shell', 3)
99

@@ -154,9 +154,14 @@ endfunction
154154
function! s:make_cmd(command)
155155
let command = a:command . ' 2>&1'
156156
let result = xolox#misc#os#exec({'command': command, 'check': 0})
157+
let g:xolox#shell#make_exit_code = result['exit_code']
157158
return join(result['stdout'], "\n")
158159
endfunction
159160

161+
if !exists('g:xolox#shell#make_exit_code')
162+
let g:xolox#shell#make_exit_code = 0
163+
endif
164+
160165
function! xolox#shell#maximize(...) " {{{1
161166
" Show/hide Vim's menu, tool bar and/or tab line.
162167
let new_state = a:0 == 0 ? !s:maximized : a:1

doc/shell.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ This command is a very simple replacement for the |:make| command that does not
107107
pop up a console window on Windows. It doesn't come with all of the bells and
108108
whistles that Vim's built-in make command does but it should work.
109109

110+
Because Vim's |v:shell_error| variable is read only (which means it cannot be
111+
set by a Vim plug-in) the vim-shell plug-in defines its own variable with the
112+
exit code of the 'make' process executed by |:MakeWithShell|. This variable is
113+
called 'g:xolox#shell#make_exit_code'. The semantics are exactly the same as
114+
for |v:shell_error|.
115+
110116
-------------------------------------------------------------------------------
111117
The *xolox#misc#os#exec()* function
112118

0 commit comments

Comments
 (0)