kien / ctrlp.vim

Fuzzy file, buffer, mru, tag, etc finder.
kien.github.com/ctrlp.vim
7.26k stars 676 forks source link

Backslash issue when using ctrlp_user_command and Cygwin bash #623

Open brkpt opened 9 years ago

brkpt commented 9 years ago

I am modifying JamPlus to generate a list of files used by a project that can be used by CtrlP and ctags. I ran into a small issue with using the ctrlp_user_command combined with using a Cygwin bash shell in the process.

If you use Cygwin bash as your VIM shell, and try to use ctrlp_user_command to read in the file list from another file, it fails because, evidently, getcwd() returns a path with backslashes in it.

set shell=e:/cygwin/bin/bash set shellslash set shellcmdflag=-c set shellxquote=\" let g:ctrlp_user_command = 'cat %s/build/workspace.vs2013/targetinfo/filelist'

This will cause it to issue the command "cat d:\project\build/workspace.vs2013/targetinfo/filelist' to bash, which will fail due to the backslashes.

The workaround I found is to force all of the backslashes to forward slashes before passing it to the system command.

diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 19ac146..2584dde --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -391,7 +391,7 @@ fu! s:UserCmd(lscmd) let lscmd = substitute(lscmd, '\v(^|&&\s_)\zscd (/d)@!', 'cd /d ', '') en let path = exists('_shellescape') ? shellescape(path) : path

This may not work for people who require forward slashes, so it would be nice if there were an option available to tell it to force the path to be all forward slashes before shelling out to the command shell.