Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: join the shell opts to a string in suda#systemlist #78

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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