title: Either getting original return value from xargs or simulate xargs
body: <p>I am working with bash. I have a file F containing the command-line arguments for a Java program, and I need to store <strong>both</strong> outputs of the Java programs, i.e., output on standard output and the exit value. Storing the standard output works via</p>
  
  <pre><code>cat F | xargs java program &gt; Output
  </code></pre>
  
  <p>But xargs does not give access to the exit-code of the Java program.
  So well, I split it, running the program twice, once for standard output, once for the exit code --- but getting the exit code and running it correctly seems impossible. One might try</p>
  
  <pre><code>java program $(cat F)
  </code></pre>
  
  <p>but that doesn't work if F contains for example " ", namely one command-line argument for program which is a space. The problem is the expansion of the argument $(cat F).</p>
  
  <p>Now I don't see a way to get around that problem? I don't want "$(cat F)", since I want that $(cat F) expands into many strings --- but I don't want further expansion of these strings.</p>
  
  <p>If on the other hand there would be a better xargs, giving access to the original exit value, that would solve the problem, but I am not aware of that.</p>