Closed kreikey closed 6 years ago
shellescape()
instead of substitute()
.Fix #34
" in the commit message, so that Github will know to connect them.shellescape() doesn’t work. I get the following error: Error detected while processing function dutyl#dComplete[38]..dutyl#core#gatherCommonArguments[8]..388[3]..dutyl#util#runInDirectory: line 13: E344: Can't find directory "'/Users/kreikey/Developer/D Programming/EulerD/27'" in cdpath
On Nov 16, 2017, at 12:28 PM, Idan Arye notifications@github.com wrote:
Please use shellescape() instead of substitute(). Please write "Fix #34" in the commit message, so that Github will know to connect them. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/idanarye/vim-dutyl/pull/37#issuecomment-345052490, or mute the thread https://github.com/notifications/unsubscribe-auth/AIDVoKsVCwJuOD0tCp7ir4c4GNN1ktqKks5s3JrZgaJpZM4QhD7W.
This pull request fixes the issue listed under "Issues" titled "Paths with spaces don't work." I've copied the code listed there verbatim and tested it on my machine. It works to my satisfaction. The code used is:
"lcd to the directory, run the function or command, and return to the current "directory function! dutyl#util#runInDirectory(directory,action,...) abort let l:cwd=getcwd() try let l:directory = substitute(a:directory, "\ ", '\ ', "g") execute 'lcd '.l:directory if type(function('tr'))==type(a:action) return call(a:action,a:000) elseif type('')==type(a:action) execute a:action endif finally let l:cwd = substitute(l:cwd, "\ ", '\ ', "g") execute 'lcd '.l:cwd endtry endfunction