Do not escape simple shell arguments

Regexp taken from vim-fugitive s:shellesc().
This commit is contained in:
Jan Edmund Lazo 2020-04-05 00:18:32 -04:00
parent eb00506f36
commit ba7ddedb9a
No known key found for this signature in database
GPG Key ID: 64915E6E9F735B15

View File

@ -2069,6 +2069,9 @@ endfunction
" If unset, fallback to 'cmd.exe' on Windows or 'sh'.
" - script: If truthy and shell is cmd.exe, escape for batchfile syntax.
function! plug#shellescape(arg, ...)
if a:arg =~# '^[A-Za-z0-9_/:.-]\+$'
return a:arg
endif
let opts = a:0 > 0 && type(a:1) == s:TYPE.dict ? a:1 : {}
let shell = get(opts, 'shell', s:is_win ? 'cmd.exe' : 'sh')
let script = get(opts, 'script', 1)