title: How do I assign the result of a function to a variable?
body: <p>I have made the following function to calculate the maximum value of an array:</p>
  <pre><code>MaxArray(){
  aux =&quot;$1&quot;
  for n in &quot;$@&quot;
  do
      [ &quot;$n&quot; -gt &quot;$aux&quot; ] &amp;&amp; aux=&quot;$n&quot;
  done
  return $aux
  }
  </code></pre>
  <p>I tried changing return to echo &quot;$aux&quot; to see if it calculated the value correctly and it worked. With an array with the following values: (1, 10, 152, 0, 3), I tried return and called the function like this:</p>
  <pre><code>value=$( MaxArray ${array[@]} )
  echo &quot;value is $value&quot;
  </code></pre>
  <p>But $value is empty after calling the function.
  How can I assign the return of the function to $value correctly?</p>