File tree Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Expand file tree Collapse file tree 1 file changed +11
-6
lines changed Original file line number Diff line number Diff line change 3
3
" {opts} should be *sudo-specific*, while {cmd} is passed to any suda#executable
4
4
" Note: {cmd} can not have any sudo flags. Put these into {opts}, as '--' is passed before {cmd}
5
5
" Similarly, {opts} should *not* contain '--'
6
+ " Returns a string that is safe to pass to `system` on both vim and neovim
6
7
function ! s: get_command (opts, cmd)
7
8
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
9
16
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 ) }), ' ' )
15
20
endfunction
16
21
17
22
" {cmd} is a argv list for the process
You can’t perform that action at this time.
0 commit comments