title: zsh: Command substitution and proper quoting
body: <p>I have a script <code>P</code> which accepts file names as parameters:</p>
  
  <pre><code>P file1 file2 file3 ....
  </code></pre>
  
  <p>I also have a script <code>G</code> which generates a (typically short list) of file names, one file name per line. In a master script which I would like to write in <em>zsh</em>, I want to use <code>G</code> to generate the file names to be processed by <code>P</code>. The naive attempt goes like this:</p>
  
  <pre><code>P $(G)
  </code></pre>
  
  <p>This works nearly well, only that I'm living in a world where malicious people enjoy creating files with embedded spaces. If <code>G</code> would generate the list of files like this:</p>
  
  <pre><code>one_file 
  a file with spaces
  </code></pre>
  
  <p><code>P</code> would be called as</p>
  
  <pre><code>P one_file a file with spaces
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>P 'one_file' 'a file with spaces'
  </code></pre>
  
  <p>One obvious solution would be to glue <code>G</code> and <code>P</code> together not by command substitution, but by a small program in some language (Ruby, Perl, Python, Algol68,....), which does an exec of <code>P</code> and passes the parameters to a read from stdin. </p>
  
  <p>This would be trivial to write and could even be made reusable. However, I wonder, whether <em>zsh</em> with its grabbag of goodies would not have a solution for this problem builtin?</p>