diff options
author | Peter Odding <peter@peterodding.com> | 2011-11-24 23:40:51 +0100 |
---|---|---|
committer | Peter Odding <peter@peterodding.com> | 2011-11-24 23:40:51 +0100 |
commit | 9b4c7741d5e00d92406538f8e86e279d82c498e8 (patch) | |
tree | d8771882857594691a2999b9c5787e91d5bb9117 | |
parent | d7b3e0cb4d4343316d53346b1cf7b77b32ed58a9 (diff) | |
download | vim-easytags-9b4c7741d5e00d92406538f8e86e279d82c498e8.tar.gz |
xolox#misc#os#exec() uses xolox#shell#execute() when available, falls back to system()
-rw-r--r-- | os.vim | 20 |
1 files changed, 19 insertions, 1 deletions
@@ -1,12 +1,30 @@ " Vim auto-load script " Author: Peter Odding <peter@peterodding.com> -" Last Change: March 15, 2011 +" Last Change: November 24, 2011 " URL: http://peterodding.com/code/vim/misc/ +let g:xolox#misc#os#version = '0.1' + " Check whether Vim is running on Microsoft Windows. function! xolox#misc#os#is_win() return has('win16') || has('win32') || has('win64') endfunction +" Execute an external command (hiding the console on Windows when possible). + +function! xolox#misc#os#exec(cmdline, ...) + try + " Try using my shell.vim plug-in. + return call('xolox#shell#execute', [a:cmdline, 1] + a:000) + catch /^Vim\%((\a\+)\)\=:E117/ + " Fall back to system() when we get an "unknown function" error. + let output = call('system', [a:cmdline] + a:000) + if v:shell_error + throw printf("os.vim %s: Command %s failed: %s", g:xolox#misc#os#version, a:cmdline, xolox#misc#str#trim(output)) + endif + return split(output, "\n") + endtry +endfunction + " vim: ts=2 sw=2 et |