From 83b94248ce1d95d3498a7c69ada26abcf4a0bae8 Mon Sep 17 00:00:00 2001 From: Gary Geng Date: Sun, 26 Feb 2023 19:38:19 -0800 Subject: [PATCH 1/5] Fix fzf#shellescape() quoting for PowerShell --- plugin/fzf.vim | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 94065e3c262..a8a07d6698e 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -83,18 +83,22 @@ else endfunction endif -function! s:shellesc_cmd(arg) +function! s:shellesc_win(arg) let escaped = substitute(a:arg, '[&|<>()@^]', '^&', 'g') let escaped = substitute(escaped, '%', '%%', 'g') let escaped = substitute(escaped, '"', '\\^&', 'g') let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g') - return '^"'.substitute(escaped, '\(\\\+\)$', '\1\1', '').'^"' + let quote_str= '^"' + if (&shell ==? 'powershell' || &shell ==? 'pwsh') + let quote_str= '"' + endif + return quoteStr.substitute(escaped, '\(\\\+\)$', '\1\1', '').quoteStr endfunction function! fzf#shellescape(arg, ...) let shell = get(a:000, 0, s:is_win ? 'cmd.exe' : 'sh') if shell =~# 'cmd.exe$' - return s:shellesc_cmd(a:arg) + return s:shellesc_win(a:arg) endif try let [shell, &shell] = [&shell, shell] From 7ef8d9b22e80d6a729e9eac3c5bf8777633e02f6 Mon Sep 17 00:00:00 2001 From: Gary Geng Date: Sun, 26 Feb 2023 19:43:18 -0800 Subject: [PATCH 2/5] Fix typo --- plugin/fzf.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index a8a07d6698e..739910e98ee 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -92,7 +92,7 @@ function! s:shellesc_win(arg) if (&shell ==? 'powershell' || &shell ==? 'pwsh') let quote_str= '"' endif - return quoteStr.substitute(escaped, '\(\\\+\)$', '\1\1', '').quoteStr + return quote_str.substitute(escaped, '\(\\\+\)$', '\1\1', '').quote_str endfunction function! fzf#shellescape(arg, ...) From 3953c91d9afb280bccf040a70290eac5b4234770 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Tue, 21 Mar 2023 16:21:34 +0900 Subject: [PATCH 3/5] Update plugin/fzf.vim --- plugin/fzf.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 739910e98ee..015a7946813 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -90,7 +90,7 @@ function! s:shellesc_win(arg) let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g') let quote_str= '^"' if (&shell ==? 'powershell' || &shell ==? 'pwsh') - let quote_str= '"' + let quote_str= '"' endif return quote_str.substitute(escaped, '\(\\\+\)$', '\1\1', '').quote_str endfunction From e2e3d36a5833264275afdb1d3326107aaba84eec Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 28 Apr 2023 23:18:40 +0900 Subject: [PATCH 4/5] Update plugin/fzf.vim --- plugin/fzf.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 015a7946813..9dcd9ca5f2b 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -89,7 +89,7 @@ function! s:shellesc_win(arg) let escaped = substitute(escaped, '"', '\\^&', 'g') let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g') let quote_str= '^"' - if (&shell ==? 'powershell' || &shell ==? 'pwsh') + if &shell =~ 'powershell\|pwsh' let quote_str= '"' endif return quote_str.substitute(escaped, '\(\\\+\)$', '\1\1', '').quote_str From 0045dfc4eb584e5a04d30ff256fc447392ca2a30 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 28 Apr 2023 23:19:53 +0900 Subject: [PATCH 5/5] Update plugin/fzf.vim --- plugin/fzf.vim | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/plugin/fzf.vim b/plugin/fzf.vim index 9dcd9ca5f2b..fea201066b7 100644 --- a/plugin/fzf.vim +++ b/plugin/fzf.vim @@ -88,10 +88,7 @@ function! s:shellesc_win(arg) let escaped = substitute(escaped, '%', '%%', 'g') let escaped = substitute(escaped, '"', '\\^&', 'g') let escaped = substitute(escaped, '\(\\\+\)\(\\^\)', '\1\1\2', 'g') - let quote_str= '^"' - if &shell =~ 'powershell\|pwsh' - let quote_str= '"' - endif + let quote_str = &shell =~ 'powershell\|pwsh' ? '"' : '^"' return quote_str.substitute(escaped, '\(\\\+\)$', '\1\1', '').quote_str endfunction