Skip to content
Myr

[vim] Fix argument escaping for Windows batch file

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Fix #3620

authored by Junegunn Choi · committed by Junegunn Choi · parent a9811ad · Browse files · 2 files+22 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+22 added−5 removed

  • other:+22 added−5 removed

2 files+22 added−5 removed

modified:plugin/fzf.vim+21 added-5 removed
81 unmodified lines
82 return a:str83 endfunction84endif8586let s:cmd_control_chars = ['&', '|', '<', '>', '(', ')', '@', '^', '!']8788function! s:shellesc_cmd(arg)87 let escaped = substitute(a:arg, '[&|<>()@^]', '^&', 'g')88 let escaped = substitute(escaped, '%', '%%', 'g')89 let escaped = substitute(escaped, '"', '\\^&', 'g')90 let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g')91 return '^"'.substitute(escaped, '\(\\\+\)$', '\1\1', '').'^"'89 let e = '"'90 let slashes = 091 for c in split(a:arg, '\zs')92 if c ==# '\'93 let slashes += 194 elseif c ==# '"'95 let e .= repeat('\', slashes + 1)96 let slashes = 097 elseif c ==# '%'98 let e .= '%'99 elseif index(s:cmd_control_chars, c) >= 0100 let e .= '^'101 else102 let slashes = 0103 endif104 let e .= c105 endfor106 let e .= repeat('\', slashes) .'"'107 return e108endfunction109110function! fzf#shellescape(arg, ...)111 let shell = get(a:000, 0, s:is_win ? 'cmd.exe' : 'sh')
1003 unmodified lines
modified:CHANGELOG.md+1 added
25 unmodified lines
26 - `change-multi(NUM)` - enable multi-select mode with a limit27 - `change-multi(0)` - disable multi-select mode28- `become` action is now supported on Windows29 - Unlike in *nix, this does not use `execve(2)`. Instead it spawns a new process and waits for it to finish, so the exact behavior may differ.30- Fixed argument escaping for Windows cmd.exe31- Bug fixes and improvements32330.50.034------
2013 unmodified lines