mirror of
https://github.com/junegunn/fzf.git
synced 2025-05-19 04:40:22 -07:00
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 "&|<>()@^%!"
This commit is contained in:
parent
24ff66d4a9
commit
5669f48343
@ -821,7 +821,7 @@ e.g. \fBfzf --multi | fzf --sync\fR
|
|||||||
.B "--with-shell=STR"
|
.B "--with-shell=STR"
|
||||||
Shell command and flags to start child processes with. On *nix Systems, the
|
Shell command and flags to start child processes with. On *nix Systems, the
|
||||||
default value is \fB$SHELL -c\fR if \fB$SHELL\fR is set, otherwise \fBsh -c\fR.
|
default value is \fB$SHELL -c\fR if \fB$SHELL\fR is set, otherwise \fBsh -c\fR.
|
||||||
On Windows, the default value is \fBcmd /v:on/s/c\fR when \fB$SHELL\fR is not
|
On Windows, the default value is \fBcmd /s/c\fR when \fB$SHELL\fR is not
|
||||||
set.
|
set.
|
||||||
|
|
||||||
.RS
|
.RS
|
||||||
|
@ -59,12 +59,9 @@ if s:is_win
|
|||||||
return iconv(a:str, &encoding, 'cp'.s:codepage)
|
return iconv(a:str, &encoding, 'cp'.s:codepage)
|
||||||
endfunction
|
endfunction
|
||||||
function! s:wrap_cmds(cmds)
|
function! s:wrap_cmds(cmds)
|
||||||
return map([
|
return map(['@echo off']
|
||||||
\ '@echo off',
|
|
||||||
\ 'setlocal enabledelayedexpansion']
|
|
||||||
\ + (has('gui_running') ? ['set TERM= > nul'] : [])
|
\ + (has('gui_running') ? ['set TERM= > nul'] : [])
|
||||||
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds])
|
\ + (type(a:cmds) == type([]) ? a:cmds : [a:cmds]),
|
||||||
\ + ['endlocal'],
|
|
||||||
\ '<SID>enc_to_cp(v:val."\r")')
|
\ '<SID>enc_to_cp(v:val."\r")')
|
||||||
endfunction
|
endfunction
|
||||||
else
|
else
|
||||||
@ -83,8 +80,6 @@ else
|
|||||||
endfunction
|
endfunction
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let s:cmd_control_chars = ['&', '|', '<', '>', '(', ')', '@', '^', '!']
|
|
||||||
|
|
||||||
function! s:shellesc_cmd(arg)
|
function! s:shellesc_cmd(arg)
|
||||||
let e = '"'
|
let e = '"'
|
||||||
let slashes = 0
|
let slashes = 0
|
||||||
@ -94,10 +89,6 @@ function! s:shellesc_cmd(arg)
|
|||||||
elseif c ==# '"'
|
elseif c ==# '"'
|
||||||
let e .= repeat('\', slashes + 1)
|
let e .= repeat('\', slashes + 1)
|
||||||
let slashes = 0
|
let slashes = 0
|
||||||
elseif c ==# '%'
|
|
||||||
let e .= '%'
|
|
||||||
elseif index(s:cmd_control_chars, c) >= 0
|
|
||||||
let e .= '^'
|
|
||||||
else
|
else
|
||||||
let slashes = 0
|
let slashes = 0
|
||||||
endif
|
endif
|
||||||
|
@ -42,7 +42,7 @@ func NewExecutor(withShell string) *Executor {
|
|||||||
args = args[1:]
|
args = args[1:]
|
||||||
} else if strings.HasPrefix(basename, "cmd") {
|
} else if strings.HasPrefix(basename, "cmd") {
|
||||||
shellType = shellTypeCmd
|
shellType = shellTypeCmd
|
||||||
args = []string{"/v:on/s/c"}
|
args = []string{"/s/c"}
|
||||||
} else if strings.HasPrefix(basename, "pwsh") || strings.HasPrefix(basename, "powershell") {
|
} else if strings.HasPrefix(basename, "pwsh") || strings.HasPrefix(basename, "powershell") {
|
||||||
shellType = shellTypePowerShell
|
shellType = shellTypePowerShell
|
||||||
args = []string{"-NoProfile", "-Command"}
|
args = []string{"-NoProfile", "-Command"}
|
||||||
@ -119,8 +119,6 @@ func escapeArg(s string) string {
|
|||||||
slashes = 0
|
slashes = 0
|
||||||
case '\\':
|
case '\\':
|
||||||
slashes++
|
slashes++
|
||||||
case '&', '|', '<', '>', '(', ')', '@', '^', '%', '!':
|
|
||||||
b = append(b, '^')
|
|
||||||
case '"':
|
case '"':
|
||||||
for ; slashes > 0; slashes-- {
|
for ; slashes > 0; slashes-- {
|
||||||
b = append(b, '\\')
|
b = append(b, '\\')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user