crosh: move remaining global code into functions

With this, we have very little code outside of functions now.  Just
the initial traps, bash re-exec, and the main call.  This follows our
shell style guide and makes it easier to reason about the code.

BUG=None
TEST=ran crosh and tested commands still worked
TEST=ran crosh with --usb and --dev and --dash and made sure things worked

Change-Id: I0a0ab0b73ed4045c4553c867cd871624698ff4c3
Reviewed-on: https://chromium-review.googlesource.com/178935
Reviewed-by: Chris Masone <cmasone@chromium.org>
Commit-Queue: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
1 file changed