From e6e8cdc0c5f06b91ffdb8b8145380837da961cf1 Mon Sep 17 00:00:00 2001 From: Bob Hiestand Date: Tue, 24 Nov 2009 08:51:04 -0600 Subject: [PATCH] Added s:Executable() function to all plugins. s:Executable() returns the name of the executable quoted to preserve spaces. --- plugin/vcsbzr.vim | 15 +++++++++++---- plugin/vcscvs.vim | 11 +++++++++-- plugin/vcsgit.vim | 17 ++++++++++++----- plugin/vcshg.vim | 17 ++++++++++++----- plugin/vcssvk.vim | 13 ++++++++++--- plugin/vcssvn.vim | 11 +++++++++-- 6 files changed, 63 insertions(+), 21 deletions(-) diff --git a/plugin/vcsbzr.vim b/plugin/vcsbzr.vim index 58d487d..2fe5f24 100644 --- a/plugin/vcsbzr.vim +++ b/plugin/vcsbzr.vim @@ -60,12 +60,19 @@ let s:bzrFunctions = {} " Section: Utility functions {{{1 +" Function: s:Executable() {{{2 +" Returns the executable used to invoke bzr suitable for use in a shell +" command. +function! s:Executable() + return shellescape(VCSCommandGetOption('VCSCommandBZRExec', 'bzr')) +endfunction + " Function: s:DoCommand(cmd, cmdName, statusText) {{{2 " Wrapper to VCSCommandDoCommand to add the name of the BZR executable to the " command argument. function! s:DoCommand(cmd, cmdName, statusText, options) if VCSCommandGetVCSType(expand('%')) == 'BZR' - let fullCmd = VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' ' . a:cmd + let fullCmd = s:Executable() . ' ' . a:cmd return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) else throw 'BZR VCSCommand plugin called on non-BZR item.' @@ -77,7 +84,7 @@ endfunction " Function: s:bzrFunctions.Identify(buffer) {{{2 function! s:bzrFunctions.Identify(buffer) let fileName = resolve(bufname(a:buffer)) - let statusText = system(VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' info -- "' . fileName . '"') + let statusText = system(s:Executable() . ' info -- "' . fileName . '"') if(v:shell_error) return 0 else @@ -162,8 +169,8 @@ endfunction function! s:bzrFunctions.GetBufferInfo() let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) let fileName = resolve(bufname(originalBuffer)) - let statusText = system(VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' status -S -- "' . fileName . '"') - let revision = system(VCSCommandGetOption('VCSCommandBZRExec', 'bzr') . ' revno -- "' . fileName . '"') + let statusText = system(s:Executable() . ' status -S -- "' . fileName . '"') + let revision = system(s:Executable() . ' revno -- "' . fileName . '"') if(v:shell_error) return [] endif diff --git a/plugin/vcscvs.vim b/plugin/vcscvs.vim index 14a9e28..2a71808 100644 --- a/plugin/vcscvs.vim +++ b/plugin/vcscvs.vim @@ -106,12 +106,19 @@ let s:cvsFunctions = {} " Section: Utility functions {{{1 +" Function: s:Executable() {{{2 +" Returns the executable used to invoke cvs suitable for use in a shell +" command. +function! s:Executable() + return shellescape(VCSCommandGetOption('VCSCommandCVSExec', 'cvs')) +endfunction + " Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2 " Wrapper to VCSCommandDoCommand to add the name of the CVS executable to the " command argument. function! s:DoCommand(cmd, cmdName, statusText, options) if VCSCommandGetVCSType(expand('%')) == 'CVS' - let fullCmd = VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' ' . a:cmd + let fullCmd = s:Executable() . ' ' . a:cmd let ret = VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) if ret > 0 @@ -294,7 +301,7 @@ function! s:cvsFunctions.GetBufferInfo() endif let oldCwd = VCSCommandChangeToCurrentFileDir(fileName) try - let statusText=system(VCSCommandGetOption('VCSCommandCVSExec', 'cvs') . ' status -- "' . realFileName . '"') + let statusText=system(s:Executable() . ' status -- "' . realFileName . '"') if(v:shell_error) return [] endif diff --git a/plugin/vcsgit.vim b/plugin/vcsgit.vim index b7e6f6f..1868524 100644 --- a/plugin/vcsgit.vim +++ b/plugin/vcsgit.vim @@ -65,12 +65,19 @@ let s:gitFunctions = {} " Section: Utility functions {{{1 +" Function: s:Executable() {{{2 +" Returns the executable used to invoke git suitable for use in a shell +" command. +function! s:Executable() + return shellescape(VCSCommandGetOption('VCSCommandGitExec', 'git')) +endfunction + " Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2 " Wrapper to VCSCommandDoCommand to add the name of the git executable to the " command argument. function! s:DoCommand(cmd, cmdName, statusText, options) if VCSCommandGetVCSType(expand('%')) == 'git' - let fullCmd = VCSCommandGetOption('VCSCommandGitExec', 'git',) . ' ' . a:cmd + let fullCmd = s:Executable() . ' ' . a:cmd return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) else throw 'git VCSCommand plugin called on non-git item.' @@ -85,7 +92,7 @@ endfunction function! s:gitFunctions.Identify(buffer) let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(a:buffer))) try - call system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' rev-parse --is-inside-work-tree') + call system(s:Executable() . ' rev-parse --is-inside-work-tree') if(v:shell_error) return 0 else @@ -177,7 +184,7 @@ endfunction function! s:gitFunctions.GetBufferInfo() let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname('%'))) try - let branch = substitute(system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' symbolic-ref -q HEAD'), '\n$', '', '') + let branch = substitute(system(s:Executable() . ' symbolic-ref -q HEAD'), '\n$', '', '') if v:shell_error let branch = 'DETACHED' else @@ -190,7 +197,7 @@ function! s:gitFunctions.GetBufferInfo() if method != '' let method = ' --' . method endif - let tag = substitute(system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' describe' . method), '\n$', '', '') + let tag = substitute(system(s:Executable() . ' describe' . method), '\n$', '', '') if !v:shell_error call add(info, tag) break @@ -227,7 +234,7 @@ function! s:gitFunctions.Review(argList) let oldCwd = VCSCommandChangeToCurrentFileDir(resolve(bufname(VCSCommandGetOriginalBuffer('%')))) try - let prefix = system(VCSCommandGetOption('VCSCommandGitExec', 'git') . ' rev-parse --show-prefix') + let prefix = system(s:Executable() . ' rev-parse --show-prefix') finally call VCSCommandChdir(oldCwd) endtry diff --git a/plugin/vcshg.vim b/plugin/vcshg.vim index 0a31063..26f82ac 100644 --- a/plugin/vcshg.vim +++ b/plugin/vcshg.vim @@ -67,12 +67,19 @@ let s:hgFunctions = {} " Section: Utility functions {{{1 +" Function: s:Executable() {{{2 +" Returns the executable used to invoke hg suitable for use in a shell +" command. +function! s:Executable() + return shellescape(VCSCommandGetOption('VCSCommandHGExec', 'hg')) +endfunction + " Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2 " Wrapper to VCSCommandDoCommand to add the name of the HG executable to the " command argument. function! s:DoCommand(cmd, cmdName, statusText, options) if VCSCommandGetVCSType(expand('%')) == 'HG' - let fullCmd = VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' ' . a:cmd + let fullCmd = s:Executable() . ' ' . a:cmd return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) else throw 'HG VCSCommand plugin called on non-HG item.' @@ -83,7 +90,7 @@ endfunction " Function: s:hgFunctions.Identify(buffer) {{{2 function! s:hgFunctions.Identify(buffer) - call system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' root') + call system(s:Executable() . ' root') if(v:shell_error) return 0 else @@ -188,7 +195,7 @@ endfunction function! s:hgFunctions.GetBufferInfo() let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) let fileName = bufname(originalBuffer) - let statusText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' status -- "' . fileName . '"') + let statusText = system(s:Executable() . ' status -- "' . fileName . '"') if(v:shell_error) return [] endif @@ -198,10 +205,10 @@ function! s:hgFunctions.GetBufferInfo() return ['Unknown'] endif - let parentsText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' parents -- "' . fileName . '"') + let parentsText = system(s:Executable() . ' parents -- "' . fileName . '"') let [revision] = matchlist(parentsText, '^changeset:\s\+\(\S\+\)\n')[1] - let logText = system(VCSCommandGetOption('VCSCommandHGExec', 'hg') . ' log -- "' . fileName . '"') + let logText = system(s:Executable() . ' log -- "' . fileName . '"') let [repository] = matchlist(logText, '^changeset:\s\+\(\S\+\)\n')[1] if revision == '' diff --git a/plugin/vcssvk.vim b/plugin/vcssvk.vim index fa13440..d513536 100644 --- a/plugin/vcssvk.vim +++ b/plugin/vcssvk.vim @@ -60,12 +60,19 @@ let s:svkFunctions = {} " Section: Utility functions {{{1 +" Function: s:Executable() {{{2 +" Returns the executable used to invoke SVK suitable for use in a shell +" command. +function! s:Executable() + return shellescape(VCSCommandGetOption('VCSCommandSVKExec', 'svk')) +endfunction + " Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2 " Wrapper to VCSCommandDoCommand to add the name of the SVK executable to the " command argument. function! s:DoCommand(cmd, cmdName, statusText, options) if VCSCommandGetVCSType(expand('%')) == 'SVK' - let fullCmd = VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' ' . a:cmd + let fullCmd = s:Executable() . ' ' . a:cmd return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) else throw 'SVK VCSCommand plugin called on non-SVK item.' @@ -82,7 +89,7 @@ function! s:svkFunctions.Identify(buffer) else let directoryName = fnamemodify(fileName, ':p:h') endif - let statusText = system(VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' info -- "' . directoryName . '"') + let statusText = system(s:Executable() . ' info -- "' . directoryName . '"') if(v:shell_error) return 0 else @@ -167,7 +174,7 @@ endfunction function! s:svkFunctions.GetBufferInfo() let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) let fileName = resolve(bufname(originalBuffer)) - let statusText = system(VCSCommandGetOption('VCSCommandSVKExec', 'svk') . ' status -v -- "' . fileName . '"') + let statusText = system(s:Executable() . ' status -v -- "' . fileName . '"') if(v:shell_error) return [] endif diff --git a/plugin/vcssvn.vim b/plugin/vcssvn.vim index 0fa12b1..e9c9285 100644 --- a/plugin/vcssvn.vim +++ b/plugin/vcssvn.vim @@ -67,12 +67,19 @@ let s:svnFunctions = {} " Section: Utility functions {{{1 +" Function: s:Executable() {{{2 +" Returns the executable used to invoke git suitable for use in a shell +" command. +function! s:Executable() + return shellescape(VCSCommandGetOption('VCSCommandSVNExec', 'svn')) +endfunction + " Function: s:DoCommand(cmd, cmdName, statusText, options) {{{2 " Wrapper to VCSCommandDoCommand to add the name of the SVN executable to the " command argument. function! s:DoCommand(cmd, cmdName, statusText, options) if VCSCommandGetVCSType(expand('%')) == 'SVN' - let fullCmd = VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' ' . a:cmd + let fullCmd = s:Executable() . ' ' . a:cmd return VCSCommandDoCommand(fullCmd, a:cmdName, a:statusText, a:options) else throw 'SVN VCSCommand plugin called on non-SVN item.' @@ -193,7 +200,7 @@ endfunction function! s:svnFunctions.GetBufferInfo() let originalBuffer = VCSCommandGetOriginalBuffer(bufnr('%')) let fileName = bufname(originalBuffer) - let statusText = system(VCSCommandGetOption('VCSCommandSVNExec', 'svn') . ' status --non-interactive -vu -- "' . fileName . '"') + let statusText = system(s:Executable() . ' status --non-interactive -vu -- "' . fileName . '"') if(v:shell_error) return [] endif -- 2.11.4.GIT