On Apr 13, 5:08 pm, Spiros Bousbouras <[email protected]> wrote:
> On Apr 13, 3:53 pm, Tim Chase <[email protected]> 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:

Ok , with more thought I see that it is a problem. Consider
Vsystem("command1 | redir @a> | echom 'abc' | redir END | command2")

The return value of Vsystem() should include the output of
command1 and command2 but it won't.

> 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

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