While writing my own plugins, I wish to support users who have fish or cmd.exe 
set as their shell. However, this often leads to a tedious pattern of:

if fnamemodify(&shell, ':t') ==# 'fish'
    " Fish syntax
    let cmd = ...
else if has('win32) || has('win64')
    " cmd.exe syntax
    let cmd = ...
else
    " POSIX syntax
    let cmd = ...
endif

let output = system(cmd)

I propose that the system() and systemlist() functions be extended to abstract 
these concerns away from plugin implementors. Before setting out on the 
implementation, I'd like to gather some feedback concerning the changes that I 
think would accomplish this in a backwards-compatible way.

First, I'd like to allow the first argument to system() and systemlist() to be 
a List in addition to a String. If the argument is a List, then the user's 
shell's equivalent of '&&' will be inserted between each command. That is,

`system(['command', 'echo success'])` would be semantically equivalent to 
`system('command && echo success')` if the user's shell is bash, or 
`system('command; and echo success')` if the user's shell is fish.

Handling redirection syntax is slightly trickier, because I want to support 
redirecting stdout and stderr independently of each other to a file, as well as 
keeping the stdin functionality. One solution is to allow the second argument 
to the functions to be a Dictionary with the following format:

{
   'stdin': (lines to be used for stdin of the first command, defaults to 
nothing),
   'stdout': (a file that stdout should be redirected to, defaults to being 
printed)
   'stderr': (a file that stderr should be redirected to, defaults to being 
printed)
}

Therefore, system('command', { 'stdin': 'input', 'stdout': '/dev/null', 
'stderr': '/dev/null' }) would be equivalent to system('command &> /dev/null').

I think that these options would be a huge boon to plugin authors and be great 
for people who use non-POSIX compliant shells. Are these changes acceptable? 
I'd love to hear some feedback.

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui