Skip to content

Commit

Permalink
Merge pull request #78 from aarondill/master
Browse files Browse the repository at this point in the history
  • Loading branch information
aarondill authored Apr 18, 2024
2 parents d0ccc1a + 0be5821 commit 04469d8
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions autoload/suda.vim
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,20 @@
" {opts} should be *sudo-specific*, while {cmd} is passed to any suda#executable
" Note: {cmd} can not have any sudo flags. Put these into {opts}, as '--' is passed before {cmd}
" Similarly, {opts} should *not* contain '--'
" Returns a string that is safe to pass to `system` on both vim and neovim
function! s:get_command(opts, cmd)
if g:suda#executable ==# 'sudo'
return [g:suda#executable] + a:opts + ['--'] + a:cmd
let ret = [g:suda#executable] + a:opts + ['--'] + a:cmd
else
" TODO:
" Should we pass '--' before cmd when using a custom suda#executable?
" Should suda#executable be split? Should we allow suda#executable to be a list instead?
" This behavior is entirely undocumented
let ret = [g:suda#executable] + a:cmd
endif
" TODO:
" Should we pass '--' before cmd when using a custom suda#executable?
" Should suda#executable be split? Should we allow suda#executable to be a list instead?
" This behavior is entirely undocumented
return [g:suda#executable] + a:cmd

" TODO: Should we detect `has('neovim')` and return a list to avoid a shell?
return join(map(ret, { k, v -> shellescape(v) }), ' ')
endfunction

" {cmd} is a argv list for the process
Expand Down

0 comments on commit 04469d8

Please sign in to comment.