-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 30-May-2015 05:08, Andy Russell wrote:
> 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.

So, you would need additional options for all these abstracted-away
elements (like :set shelljoiner=&&), and the user would have to
provide correct values for his shell? I see this as a downside; not
every user knows all those details about his shell.

As a plugin author, I would rather do one of the following:
- - temporarily switch the 'shell' option to the POSIX shell / Windows
cmd.exe, and only implement syntax for those two
- - as a variation of the above, extract the logic into a separate shell
script (with #!/bin/sh), and invoke this single script from Vim (for
which the default options should be sufficient)
- - offer a configuration (g:pluginname_shelltemplate = "%s && %s &>
%s") for the user to tweak (with a proper default for common shells,
so tweaking is only necessary for esoteric ones)

As a first step towards your proposed solution, you could implement a
Vimscript library that offers all of this; no changes to Vim would be
necessary (many such generic libraries already exist; see
http://www.vim.org/scripts/script.php?script_id=4433 for a list), and
it would work with existing (old) Vim versions. If this library indeed
proves to be very valuable to many plugin authors, it can later be
considered to include this (natively, or just out of the box as a
plugin like netrw) in Vim.

- -- regards, ingo
- -- 
  -- Ingo Karkat --  /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --
  --   http://vim.sourceforge.net/account/profile.php?user_id=9713   --
Using Vim for 13 years now, mostly 'cos I can't figure out how to exit i
t.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (MingW32)

iQEcBAEBAgAGBQJVaWpLAAoJEA7ziXlAzQ/vZWEH/1fCPsLvYeWr+YvcfxpBoE+2
WRe7OAL9uN7T/4izUPDfStB4aJBpRNYjoplZvwXe/P5Kr99xaxahfVdx4bTleW7m
MM4v18QnGsnwl4Sd6ZmW6y6zxKwpsWIPQMfe8TeLvl90u5CGrn5aXqja3GaCFDXZ
lSymaaM/zmM/qrrMVjoZksTS9+tOq5p2p0fDHH0ZK10p0jPW5C424xC0NT81JGV4
7sO83NWRhmDOyTflVSBoSdi/hT8sWvzPsAZVxPc3nx2RCceYTpAjC3KF4yHYWwtV
y1S5yNUhivDIhVH7lZViZckR7WponHjyMy3vLmXGvAXkG0iUtyivPqJTXZpEG3g=
=RGIb
-----END PGP SIGNATURE-----

-- 
-- 
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