cros_show_stacks: Fix bash looping.

cros_show_stacks was looping over bash space-separated strings as though
they were arrays, which resulted in the code iterating only once with
the entire string as input.

Instead, properly construct the array so that the loop works.

BUG=b:193386105
TEST=./cros_show_stacks --remote=localhost --ssh_port=2222
TEST=./cros_show_stacks missived.20210720.094829.77846.23005.dmp \
     --board=jacuzzi

Change-Id: I874f9e57ee11c86c1ab9c9edb164f1ad6e5869d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosutils/+/3039260
Tested-by: Miriam Zimmerman <mutexlox@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Miriam Zimmerman <mutexlox@chromium.org>
diff --git a/cros_show_stacks b/cros_show_stacks
index 3dfc8fa..fcdadb2 100755
--- a/cros_show_stacks
+++ b/cros_show_stacks
@@ -87,6 +87,8 @@
 
 main() {
   FLAGS "$@" || usage
+  eval set -- "${FLAGS_ARGV}"
+
   local basename=$(basename "$0")
   TMP=$(mktemp -d /tmp/${basename}.XXXX)
   trap cleanup EXIT INT TERM
@@ -129,22 +131,23 @@
     info "Copying back ${crash_count} crashes."
     crashes="${unique_crashes}"
     local filesfrom="${TMP}/filesfrom"
-    FLAGS_ARGV=""
+    declare -a dumps
     for crash in ${crashes}; do
       echo "${crash}" >> "${filesfrom}"
-      FLAGS_ARGV="${FLAGS_ARGV} '${TMP}/$(basename ${crash})'"
+      dumps+=( "${TMP}/$(basename "${crash}")" )
     done
+    set -- "$@" "${dumps[@]}"
     remote_rsync_from "${filesfrom}" "${TMP}"
     if [ ${FLAGS_clean} -eq ${FLAGS_TRUE} ]; then
       remote_sh "rm -rf ${remote_crash_dirs[*]}"
     fi
   else
-    [ -n "${FLAGS_ARGV}" ] || usage
+    [[ $# -gt 0 ]] || usage
     [ -n "${FLAGS_board}" ] || die_notrace "--board is required."
   fi
 
   local modules_file="${TMP}/modules"
-  for dump in "${FLAGS_ARGV[@]}"; do
+  for dump in "$@"; do
     dump=$(remove_quotes "${dump}")
     if [ $(get_kind "${dump}") == "minidump" ]; then
       # Find all DSOs and executables listed in lines like:
@@ -161,7 +164,7 @@
     FLAGS_breakpad_root=/build/${FLAGS_board}/usr/lib/debug/breakpad
   fi
 
-  for dump in "${FLAGS_ARGV[@]}"; do
+  for dump in "$@"; do
     dump=$(remove_quotes "${dump}")
     if [ $(get_kind "${dump}") = "minidump" ]; then
       info "Dumping stack for $(basename "${dump}")" \