title: bash function that accepts arguments and returns array to variable
body: <p>I am trying to figure if this is a syntax or logic problem with bash.</p>
  
  <p>It you can return a value from a function and assign it to a variable like;</p>
  
  <pre><code>var=$(the_function)
  </code></pre>
  
  <p>I am trying to add multiple arguments to the function call that include variables, paren <code>()</code>, double colon <code>::</code>, along with both single and double quotes with no luck.  </p>
  
  <p>an example of what i am trying is the following;</p>
  
  <pre><code>var=$(db_query "SELECT nextval('the_seq'::regclass) FROM the_table;" "$dbname")
  </code></pre>
  
  <p>the function successfully queries the database when not trying to return the value.</p>
  
  <p>I keep getting an "unexpected `)'" for the very last <code>)</code> that wraps the entire function.  I have tried numerous forms of quoting and escaping but take away <code>var=$</code> along with the wrapping ( ) and the function works as intended.</p>
  
  <p>Would this be my incorrect logic, syntax or both?</p>