From 84fcfae7f019f41f95b3ea885033346e6e66cbc3 Mon Sep 17 00:00:00 2001 From: Tim Pope Date: Wed, 1 Aug 2018 19:06:56 -0400 Subject: [PATCH] Unify shell expansion --- autoload/fugitive.vim | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/autoload/fugitive.vim b/autoload/fugitive.vim index ea44f24..594191d 100644 --- a/autoload/fugitive.vim +++ b/autoload/fugitive.vim @@ -1742,9 +1742,10 @@ function! s:Commit(mods, args, ...) abort else let command = 'env GIT_EDITOR=false ' endif - let command .= s:UserCommand() . ' commit ' . a:args + let args = s:ExecExpand(a:args) + let command .= s:UserCommand() . ' commit ' . args if &shell =~# 'csh' - noautocmd silent execute '!('.command.' > '.outfile.') >& '.errorfile + noautocmd silent execute '!('.escape(command, '!#%').' > '.outfile.') >& '.errorfile elseif a:args =~# '\%(^\| \)-\%(-interactive\|p\|-patch\)\>' noautocmd execute '!'.command.' 2> '.errorfile else @@ -1769,17 +1770,10 @@ function! s:Commit(mods, args, ...) abort let errors = readfile(errorfile) let error = get(errors,-2,get(errors,-1,'!')) if error =~# 'false''\=\.$' - let args = a:args let args = s:gsub(args,'%(%(^| )-- )@' @@ -1996,7 +1990,7 @@ function! s:Grep(cmd,bang,arg) abort execute cd s:fnameescape(s:Tree()) let &grepprg = s:UserCommand() . ' --no-pager grep -n --no-color' let &grepformat = '%f:%l:%m,%m %f match%ts,%f' - exe a:cmd.'! '.escape(matchstr(a:arg,'\v\C.{-}%($|[''" ]\@=\|)@='),'|') + exe a:cmd.'! '.escape(s:ExecExpand(matchstr(a:arg, '\v\C.{-}%($|[''" ]\@=\|)@=')), '|#%') let list = a:cmd =~# '^l' ? getloclist(0) : getqflist() for entry in list if bufname(entry.bufnr) =~ ':' @@ -2041,7 +2035,7 @@ function! s:Log(cmd, bang, line1, line2, ...) abort let cmd += [s:Relative('')[5:-1]] endif end - let cmd += map(copy(a:000),'s:sub(v:val,"^\\%(%(:\\w)*)","\\=fnamemodify(s:Relative(''),submatch(1))")') + let cmd += map(copy(a:000),'s:ExecExpand(v:val)') if path =~# '/.' if a:line2 let cmd += ['-L', a:line1 . ',' . a:line2 . ':' . path[1:-1]]