mirror of
https://github.com/flatcar/scripts.git
synced 2025-10-22 12:52:03 +02:00
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>