On Apr 13, 3:53 pm, Tim Chase <v...@tim.thechases.com> wrote:
>
> While this works for expressions (the followup question about
> "echo 25*47"), it doesn't satisfy the OP's request for
> arbitrary > Ex commands.  Assuming the commands to be executed
> don't include redirs and there's not a redir already in process
> (that you don't want to terminate), it could be wrapped in a function
>
>   function! Capture(excmds)
>     redir => s:results
>     exec a:excmds
>     redir END
>     return s:results
>   endfunction

Regarding the situation where excmds contains redirections i.e.
the example  Vsystem("redir @a> | echom 'abc' | redir END")
posted earlier by ZyX , I don't consider it a problem. I hadn't
thought of this scenario when I suggested Vsystem() but it
makes more sense to me that if some commands in Vsystem's
argument redirect their output then this output should not be
included in Vsystem's return value.

Consider the analogous situation with shell programming:

prompt> shell-script
...
Get stuff on the screen
...

prompt> shell-script > file1
Now stdout goes into file1

But if inside shell-script there is somewhere
command > file2

then the output of command will still go to file2 even when I
do   shell-script > file1


On the other hand , the fact that Capture() will mess up any
redirection set up before calling Capture() is a problem. I
don't think there's a way to solve this with what vim presently
offers.

[...]

> Hope this helps,

It's good enough for government work. Thank you.

-- 
You received this message from the "vim_use" 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

Reply via email to