title: Bash function, array howto?
body: <p>I'm struggling to wrap my head around Bash arrays, in particular I have this function where I need to load an array; What I have written is this:</p>
  
  <p><code>
  function list_files() {
      for f in *; do
          [[ -e $f ]] || continue
      done
  }</p>
  
  <pre><code>function list_array() {
  
      array=list_files
      number=0
  
      for items in "${array[@]}"
      do
              let "number +=1"
              echo -e "\033[1m$number\033[0m) $items"
              tput sgr0
              let "number -=$(echo "${#array[*]}")"
      done
  }
  </code></pre>
  
  <p></code>
  The problem here is that the function only works once, however I need to run this several times in the script. I am unsure how to go about doing this. Either I have to empty and reload the array every time the function is invoked, or I have to supply a different array name in the function parameter (list_array myarrayname in stead of just list_array). However I have no idea how to accomplish either of these tasks, or if they are possible/feasible.</p>
  
  <p>Any help would be very welcomed!</p>