From a8dfdd40b749f2a27ac3471a8bbc39c8b5e31431 Mon Sep 17 00:00:00 2001 From: hanhuanle Date: Wed, 27 Apr 2016 22:41:47 +0800 Subject: [PATCH] shellescape file path when call "system()" "system()" called by "get_git_untracked" and "get_hg_untracked" fails sometimes. It reports error "Can't open file /tmp/***". The root cause is that the file path for system() contains some unordinary character and lacks quotes. --- autoload/airline/extensions/branch.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/airline/extensions/branch.vim b/autoload/airline/extensions/branch.vim index 6b31c7de..2157547d 100644 --- a/autoload/airline/extensions/branch.vim +++ b/autoload/airline/extensions/branch.vim @@ -73,7 +73,7 @@ function! s:get_git_untracked(file) if has_key(s:untracked_git, a:file) let untracked = s:untracked_git[a:file] else - let output = system('git status --porcelain -- '. a:file) + let output = system('git status --porcelain -- '. shellescape(a:file)) if output[0:1] is# '??' && output[3:-2] is? a:file let untracked = get(g:, 'airline#extensions#branch#notexists', g:airline_symbols.notexists) endif @@ -92,7 +92,7 @@ function! s:get_hg_untracked(file) if has_key(s:untracked_hg, a:file) let untracked = s:untracked_hg[a:file] else - let untracked = (system('hg status -u -- '. a:file)[0] is# '?' ? + let untracked = (system('hg status -u -- '. shellescape(a:file))[0] is# '?' ? \ get(g:, 'airline#extensions#branch#notexists', g:airline_symbols.notexists) : '') let s:untracked_hg[a:file] = untracked endif