title: Resetting an array and filling it with values in a bash script
body: <p>I wanted to know the "right" way to do this. Basically, I have a list of files that are in an array called <code>current</code>. This is declared as a global variable that looks like this: <code>current=()</code>. I have successfully put all the files in this array. But now, I am going through and parsing arguments to filter out these files and directories.</p>
  
  <p>For example, to implement the <code>-name '*.pattern'</code> command, I pass in the <code>pattern</code> to <code>process_name()</code> which does this:</p>
  
  <pre><code>process_name ()
  {
      local new_cur=()
      for i in "${current[@]}"; do
          if [[ "$i" == "$1" ]]; then
              new_cur+=("$i")
          fi
      done
      current=( "${new_cur[@]}" )
  }
  </code></pre>
  
  <p>After the loop finishes I want to "clear" my <code>current</code> array. Then I want to loop over the <code>new_cur</code> array, and basically make it equal to <code>current</code>, or if I can, just do something like <code>$current = $new_cur</code> (although I know this won't work).</p>
  
  <p>I've tried doing this after the for loop (in <code>process_name()</code>), but my array <code>current</code> doesn't actually change:</p>
  
  <pre><code>current=( "${new_cur[@]}" )
  </code></pre>
  
  <p>Is there a good way to do this? Or a right way to do this?</p>