title: Using xargs to assign stdin to a variable
body: <p>All that I really want to do is make sure everything in a pipeline succeeded and assign the last stdin to a variable.  Consider the following dumbed down scenario:</p>
  
  <p><code>x=`exit 1|cat`</code></p>
  
  <p>When I run <code>declare -a</code>, I see this:</p>
  
  <p><code>declare -a PIPESTATUS='([0]="0")'</code></p>
  
  <p>I need some way to notice the <code>exit 1</code>, so I converted it to this:</p>
  
  <p><code>exit 1|cat|xargs -I {} x={}</code></p>
  
  <p>And <code>declare -a</code> gave me:</p>
  
  <p><code>declare -a PIPESTATUS='([0]="1" [1]="0" [2]="0")'</code></p>
  
  <p>That is what I wanted, so I tried to see what would happen if the <code>exit 1</code> didn't happen:</p>
  
  <p><code>echo 1|cat|xargs -I {} x={}</code></p>
  
  <p>But it fails with:</p>
  
  <p><code>xargs: x={}: No such file or directory</code></p>
  
  <p>Is there any way to have xargs assign <code>{}</code> to <code>x</code>?  What about other methods of having <code>PIPESTATUS</code> work and assigning the stdin to a variable?</p>
  
  <p>Note:  these examples are dumbed down.  I'm not really doing an <code>exit 1</code>, <code>echo 1</code> or a <code>cat</code>, but used these commands to simplify so we can focus on my particular issue.</p>