From 15450eff27be7d1f81f211aaa03d28908b5c4c1a Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Fri, 21 Mar 2014 01:38:51 -0400 Subject: [PATCH] Steal Windows shell escaping from dispatch.vim --- autoload/nrepl/fireplace_connection.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/autoload/nrepl/fireplace_connection.vim b/autoload/nrepl/fireplace_connection.vim index d876132..86f8d32 100644 --- a/autoload/nrepl/fireplace_connection.vim +++ b/autoload/nrepl/fireplace_connection.vim @@ -34,7 +34,14 @@ function! s:shellesc(arg) abort if a:arg =~ '^[A-Za-z0-9_/.-]\+$' return a:arg elseif &shell =~# 'cmd' - return '"'.substitute(substitute(a:arg, '"', '""""', 'g'), '%', '"%"', 'g').'"' + if &shellxquote ==# '"' + return '"' . substitute(a:arg, '"', '""', 'g') . '"' + else + let esc = exists('+shellxescape') ? &shellxescape : '"&|<>()@^' + return &shellxquote . + \ substitute(a:arg, '['.esc.']', '^&', 'g') . + \ get({'(': ')', '"(': ')"'}, &shellxquote, &shellxquote) + endif else let escaped = shellescape(a:arg) if &shell =~# 'sh' && &shell !~# 'csh'