From 5669f48343cac868eb7432950db61c9aa2383ab6 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Mon, 6 May 2024 12:07:51 +0900 Subject: Do not enable delayed expansion mode when running cmd.exe And simplify the argument escaping code. Fix #3764. This may breaks some existing use cases, but the mode causes too much trouble when escaping arguments and it makes some things not possible. # Now you can pass special characters to rg process without any escaping problems: &|<>()@^%! fzf --ansi --disabled --bind "change:reload:rg --column --line-number --no-heading --color=always --smart-case -- {q}" # No sudden expansion of the arguments on '!' fzf --disabled --preview "echo {q} {n} {}" --query "&|<>()@^%!" --prompt "&|<>()@^%!" --- plugin/fzf.vim | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'plugin/fzf.vim') diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 4a1ca0e5..b73f2aaa 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -59,12 +59,9 @@ if s:is_win return iconv(a:str, &encoding, 'cp'.s:codepage) endfunction function! s:wrap_cmds(cmds) - return map([ - \ '@echo off', - \ 'setlocal enabledelayedexpansion'] + return map(['@echo off'] \ + (has('gui_running') ? ['set TERM= > nul'] : []) - \ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds]) - \ + ['endlocal'], + \ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds]), \ 'enc_to_cp(v:val."\r")') endfunction else @@ -83,8 +80,6 @@ else endfunction endif -let s:cmd_control_chars = ['&', '|', '<', '>', '(', ')', '@', '^', '!'] - function! s:shellesc_cmd(arg) let e = '"' let slashes = 0 @@ -94,10 +89,6 @@ function! s:shellesc_cmd(arg) elseif c ==# '"' let e .= repeat('\', slashes + 1) let slashes = 0 - elseif c ==# '%' - let e .= '%' - elseif index(s:cmd_control_chars, c) >= 0 - let e .= '^' else let slashes = 0 endif -- cgit v1.2.3