Skip to content

Commit 04469d8

Browse files
authored
Merge pull request #78 from aarondill/master
2 parents d0ccc1a + 0be5821 commit 04469d8

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

autoload/suda.vim

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,20 @@
33
" {opts} should be *sudo-specific*, while {cmd} is passed to any suda#executable
44
" Note: {cmd} can not have any sudo flags. Put these into {opts}, as '--' is passed before {cmd}
55
" Similarly, {opts} should *not* contain '--'
6+
" Returns a string that is safe to pass to `system` on both vim and neovim
67
function! s:get_command(opts, cmd)
78
if g:suda#executable ==# 'sudo'
8-
return [g:suda#executable] + a:opts + ['--'] + a:cmd
9+
let ret = [g:suda#executable] + a:opts + ['--'] + a:cmd
10+
else
11+
" TODO:
12+
" Should we pass '--' before cmd when using a custom suda#executable?
13+
" Should suda#executable be split? Should we allow suda#executable to be a list instead?
14+
" This behavior is entirely undocumented
15+
let ret = [g:suda#executable] + a:cmd
916
endif
10-
" TODO:
11-
" Should we pass '--' before cmd when using a custom suda#executable?
12-
" Should suda#executable be split? Should we allow suda#executable to be a list instead?
13-
" This behavior is entirely undocumented
14-
return [g:suda#executable] + a:cmd
17+
18+
" TODO: Should we detect `has('neovim')` and return a list to avoid a shell?
19+
return join(map(ret, { k, v -> shellescape(v) }), ' ')
1520
endfunction
1621

1722
" {cmd} is a argv list for the process

0 commit comments

Comments
 (0)