title: idioms for returning multiple values in shell scripting
body: <p>Are there any idioms for returning multiple values from a bash function within a script?</p>
  
  <p><a href="http://tldp.org/LDP/abs/html/assortedtips.html" rel="noreferrer">http://tldp.org/LDP/abs/html/assortedtips.html</a> describes how to echo multiple values and process the results (e.g., example 35-17), but that gets tricky if some of the returned values are strings with spaces in.</p>
  
  <p>A more structured way to return would be to assign to global variables, like</p>
  
  <pre><code>foo () {
      FOO_RV1="bob"
      FOO_RV2="bill"
  }
  
  foo
  echo "foo returned ${FOO_RV1} and ${FOO_RV2}"
  </code></pre>
  
  <p>I realize that if I need re-entrancy in a shell script I'm probably doing it wrong, but I still feel very uncomfortable throwing global variables around just to hold return values.</p>
  
  <p>Is there a better way? I would prefer portability, but it's probably not a real limitation if I have to specify <code>#!/bin/bash</code>.</p>