Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't pipe into gvim from a ruby sub process
    primarykey
    data
    text
    <p>I've been attempting to use the PA_translator.vim plugin but found that it doesn't work in Win32 Gvim. This appears to be because in an embedded Vim Ruby script it's not possible to use any of the commands which pipe in from a subprocess. The original process builds a command dymanically and then launches a subprocess to obtain a JSON snippet like so:</p> <pre><code>cmd = "require 'net/http'; p Net::HTTP.get('%s', '%s')"% [host, path] response = `ruby -e "#{cmd}"` </code></pre> <p>If I run this in a command line ruby script it works fine, but inside a Vim script the pipe appears to return an empty string..</p> <p>I've also tried several other methods which produce the same result:</p> <pre><code>response = '' IO.popen("ruby.exe", "w+") do |f| f.write cmd f.close_write response = f.read p response end </code></pre> <p>And even:</p> <pre><code>def redirect orig_defout = $stdout $stdout = StringIO.new yield $stdout.string ensure $stdout = orig_defout end response = redirect { eval cmd } </code></pre> <p>All of these seem to fail for the same reason, it's not possible to get the output from the pipe and I get back an empty string. GVim is a true win32 process, is there some reason why piping from a subprocess won't work?</p> <p><strong>EDIT</strong>: If I try to capture piped output from embedded vim/perl, that works fine, so I guess it's some particular issue with the vim -> win32 -> ruby combination:</p> <pre><code>fun! SayHello() perl &lt;&lt; EOF $bob = `ls`; VIM::Msg($bob); EOF </code></pre> <p>endfun</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload