Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues 1432 #3002

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
6 changes: 5 additions & 1 deletion plugin/fzf.vim
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ endif
if s:is_win
let s:term_marker = '&::FZF'

" This is not bulletproof, but cmd.exe does not have SHELL env var.
let s:is_gitbash = has_key(environ(), 'SHELL')

function! s:fzf_call(fn, ...)
let shellslash = &shellslash
try
Expand Down Expand Up @@ -484,7 +487,8 @@ try
elseif type == 3
let temps.input = s:fzf_tempname()
call s:writefile(source, temps.input)
let source_command = (s:is_win ? 'type ' : 'cat ').fzf#shellescape(temps.input)
let source_command = (s:is_win && !s:is_gitbash ? 'type ' : 'cat ')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm not mistaken, environ() is a recent addition to Vim (after Vim 8), so it's probably safer to use exists('$VARNAME') not to break this on older Vim versions.

Suggested change
let source_command = (s:is_win && !s:is_gitbash ? 'type ' : 'cat ')
let source_command = (s:is_win && !exists('$SHELL') ? 'type ' : 'cat ')

\.(s:is_gitbash ? substitute(temps.input, '\', '/', 'g') : fzf#shellescape(temps.input))
else
throw 'Invalid source type'
endif
Expand Down