title: Process substitution (not command substitution) in Ruby
body: <p>In bash, zsh, ksh88, ksh93 and similar shells, one can trivially generate a filename (which, as appropriate to the platform, is implemented as either a <code>/dev/fd</code> entry or a named pipe) in which a given piece of code is executed in a subshell.</p>
  
  <p>I'm interested in doing the same thing in a Ruby interpreter -- executing a subprocess with one of its arguments a filename which, when read, will stream the output of code run in either the present Ruby interpreter or a subprocess of same.</p>
  
  <p>Content is security-sensitive, so writing to temporary files is not ideal.</p>
  
  <hr>
  
  <p>The equivalent code in bash:</p>
  
  <pre><code>./run-program --password-file=&lt;(printf '%s' "$password")
  </code></pre>
  
  <p>...when run, will (on Linux or another platform with <code>/dev/fd/</code>) invoke something like:</p>
  
  <pre><code>./run-program --password-file=/dev/fd/5
  </code></pre>
  
  <p>...where <code>/dev/fd/5</code> can be read from (exactly once, being a stream) to retrieve the result of expanding <code>$password</code>.</p>
  
  <hr>
  
  <p>What's the best approach to implementing the same calling convention in Ruby?</p>