Skip to content

Commit 4539a9a

Browse files
rhysdda-x
authored andcommitted
refactor s:RmDir() in autoload/rust.vim
1 parent 2965047 commit 4539a9a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

autoload/rust.vim

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,19 @@ function! s:RmDir(path)
396396
echoerr 'Attempted to delete empty path'
397397
return 0
398398
elseif a:path ==# '/' || a:path ==# $HOME
399-
echoerr 'Attempted to delete protected path: ' . a:path
399+
let l:path = expand(a:path)
400+
if l:path ==# '/' || l:path ==# $HOME
401+
echoerr 'Attempted to delete protected path: ' . a:path
402+
return 0
403+
endif
404+
endif
405+
406+
if !isdirectory(a:path)
400407
return 0
401408
endif
402-
return system("rm -rf " . shellescape(a:path))
409+
410+
" delete() returns 0 when removing file successfully
411+
return delete(a:path, 'rf') == 0
403412
endfunction
404413

405414
" Executes {cmd} with the cwd set to {pwd}, without changing Vim's cwd.

0 commit comments

Comments
 (0)