Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of https://github.com/xolox/vim-misc

  • Loading branch information...
commit 5ddefd073c03ba905c3697345a0477006dffc1e5 2 parents 4d9cf2b + 9b4c774
Peter Odding authored November 26, 2011

Showing 1 changed file with 19 additions and 1 deletion. Show diff stats Hide diff stats

  1. 20  autoload/xolox/misc/os.vim
20  autoload/xolox/misc/os.vim
... ...
@@ -1,12 +1,30 @@
1 1
 " Vim auto-load script
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: March 15, 2011
  3
+" Last Change: November 24, 2011
4 4
 " URL: http://peterodding.com/code/vim/misc/
5 5
 
  6
+let g:xolox#misc#os#version = '0.1'
  7
+
6 8
 " Check whether Vim is running on Microsoft Windows.
7 9
 
8 10
 function! xolox#misc#os#is_win()
9 11
   return has('win16') || has('win32') || has('win64')
10 12
 endfunction
11 13
 
  14
+" Execute an external command (hiding the console on Windows when possible).
  15
+
  16
+function! xolox#misc#os#exec(cmdline, ...)
  17
+  try
  18
+    " Try using my shell.vim plug-in.
  19
+    return call('xolox#shell#execute', [a:cmdline, 1] + a:000)
  20
+  catch /^Vim\%((\a\+)\)\=:E117/
  21
+    " Fall back to system() when we get an "unknown function" error.
  22
+    let output = call('system', [a:cmdline] + a:000)
  23
+    if v:shell_error
  24
+      throw printf("os.vim %s: Command %s failed: %s", g:xolox#misc#os#version, a:cmdline, xolox#misc#str#trim(output))
  25
+    endif
  26
+    return split(output, "\n")
  27
+  endtry
  28
+endfunction
  29
+
12 30
 " vim: ts=2 sw=2 et

0 notes on commit 5ddefd0

Please sign in to comment.
Something went wrong with that request. Please try again.