Mike Frysinger 61e4f2855b cros_sdk: avoid useless forks
The cros_sdk tool runs a lot of helper programs which can be replaced
with bash builtins, or condensed multiple calls into a single one.  By
themselves they aren't that slow, but add them all up and run them a
whole lot, and it starts to make a difference.

External programs to bash internals:
 - dirname $f    -> ${f%/*}
 - f=$(cat $f)   -> f=$(<$f)
 - which f       -> type -P f

Simpler expressions:
 - [[ ( ... ) ]] -> [[ ... ]]
 - eval v=\$$f   -> v=${!f}

Common/clearer expressions:
 - ! var=$(cmd)  -> var=$(cmd || :)

Condensed tools:
 - sort | uniq   -> uniq -u

BUG=None
TEST=`cros_sdk --enter` still works with simultaneous runs
TEST=`cros_sdk --enter -- ls` still works

Change-Id: Ice5e5e252237082a2249990644e051895d61d1fd
Reviewed-on: http://gerrit.chromium.org/gerrit/8029
Commit-Ready: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Mike Frysinger <vapier@chromium.org>
2011-09-30 08:53:31 -07:00
..
2011-09-30 08:53:31 -07:00