[英]How can I redirect the error stream from ruby's shell commands in vim's ruby interface?
I want to use the rake
module from vim's ruby interface to run rake files. 我想使用vim的ruby界面中的
rake
模块来运行rake文件。 When a rake task uses sh
to call shell commands, the output goes directly to the terminal - it doesn't go through ruby's $stdout
and $stderr
- when I try to redirect $stdout
and $stderr
the output doesn't go to where I redirect it. 当rake任务使用
sh
调用shell命令时,输出将直接到达终端-它不会通过ruby的$stdout
和$stderr
当我尝试重定向$stdout
和$stderr
,输出不会转到其中我重定向。
Now, in vim, that output does not go to vim's terminal - it goes to the terminal that launched vim! 现在,在vim中,该输出不会发送到vim的终端-它会发送到启动vim的终端!
stdout
is not a problem, because rake prints it where I want it. stdout
没问题,因为rake将其打印在我想要的位置。 However, if I try to use the rake module from vim's ruby interface, I don't want the error output to go to the terminal who called vim(which is hidden when running gVim and awkward when running shell vim) - I want it to go into something I can read via ruby or vimscript(so I can parse the error message) 但是,如果我尝试从vim的ruby界面使用rake模块,我不希望错误输出到调用vim的终端(在运行gVim时隐藏,而在运行shell vim时尴尬)-我希望它进入我可以通过ruby或vimscript读取的内容(以便我可以解析错误消息)
So, I'm looking for a way to: 因此,我正在寻找一种方法:
stderr
of ruby's shell calls, or stderr
,或者 stderr
that vim sends to the shell that called it. stderr
到调用它的shell。 Is it possible? 可能吗?
If you use 2>
when calling Ruby or rake, it will output stderr
to where you want it. 如果在调用Ruby或rake时使用
2>
,它将stderr
到您想要的位置。
Will output error to console: 将错误输出到控制台:
ruby -e "raise 'exception'" > output
Will output error out file called output
: 将输出错误输出文件称为
output
:
ruby -e "raise 'exception'" 2> output
Hopefully this helps! 希望这会有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.