Skip to content

Commit 942e75a

Browse files
committed
Workaround &shellslash option on Windows (issue #6)
I'm not sure if this is the right thing to do but I've had several "bug reports" about this option breaking my plug-ins. What I'm not sure about is whether this option has a legitimate use case that I'm breaking with this change... TODO If I don't get any complaints about this change I may have to move xolox#shell#escape() to xolox#misc#os#shellescape() and use it in my other plug-ins as well?
1 parent d530837 commit 942e75a

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

‎autoload/xolox/shell.vim‎

Lines changed: 18 additions & 4 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: October 28, 2011
3+
" Last Change: October 29, 2011
44
" URL: http://peterodding.com/code/vim/shell/
55

6-
let g:xolox#shell#version = '0.9.18'
6+
let g:xolox#shell#version = '0.9.20'
77

88
if !exists('s:fullscreen_enabled')
99
let s:enoimpl = "%s() hasn't been implemented on your platform! %s"
@@ -122,11 +122,11 @@ function! xolox#shell#execute(command, synchronous, ...) " -- execute external c
122122
if has_input
123123
let tempin = tempname()
124124
call writefile(type(a:1) == type([]) ? a:1 : split(a:1, "\n"), tempin)
125-
let cmd .= ' < ' . shellescape(tempin)
125+
let cmd .= ' < ' . xolox#shell#escape(tempin)
126126
endif
127127
if a:synchronous
128128
let tempout = tempname()
129-
let cmd .= ' > ' . shellescape(tempout) . ' 2>&1'
129+
let cmd .= ' > ' . xolox#shell#escape(tempout) . ' 2>&1'
130130
endif
131131
if xolox#misc#os#is_win() && s:has_dll()
132132
let fn = 'execute_' . (a:synchronous ? '' : 'a') . 'synchronous'
@@ -162,6 +162,20 @@ function! xolox#shell#execute(command, synchronous, ...) " -- execute external c
162162
endtry
163163
endfunction
164164

165+
function! xolox#shell#escape(argument) " -- quote command line arguments {{{1
166+
if xolox#misc#os#is_win()
167+
try
168+
let ssl_save = &shellslash
169+
set noshellslash
170+
return shellescape(a:argument)
171+
finally
172+
let &shellslash = ssl_save
173+
endtry
174+
else
175+
return shellescape(a:argument)
176+
endif
177+
endfunction
178+
165179
function! xolox#shell#maximize(...) " -- show/hide Vim's menu, tool bar and/or tab line {{{1
166180
let new_state = a:0 == 0 ? !s:maximized : a:1
167181
if new_state && !s:maximized

0 commit comments

Comments
 (0)