mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
cipd/python: optimize cat usage
Bash has a builtin for reading files, so use that instead of running the cat program to save on time & overhead. Change-Id: Ia90fc22a47f2ead4ef056020a79ebdebd7bd70ca Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4111082 Reviewed-by: Brian Ryner <bryner@google.com> Commit-Queue: Mike Frysinger <vapier@chromium.org> Reviewed-by: Gavin Mak <gavinmak@google.com>
This commit is contained in:
6
cipd
6
cipd
@@ -90,13 +90,13 @@ CIPD_BACKEND="https://chrome-infra-packages.appspot.com"
|
||||
VERSION_FILE="${MYPATH}/cipd_client_version"
|
||||
|
||||
CLIENT="${MYPATH}/.cipd_client"
|
||||
VERSION=`cat "${VERSION_FILE}"`
|
||||
VERSION=$(<"${VERSION_FILE}")
|
||||
PLATFORM="${OS}-${ARCH}"
|
||||
|
||||
# A value in .cipd_client_platform overrides the "guessed" platform.
|
||||
PLATFORM_OVERRIDE_FILE="${MYPATH}/.cipd_client_platform"
|
||||
if [ -f "${PLATFORM_OVERRIDE_FILE}" ]; then
|
||||
PLATFORM=`cat ${PLATFORM_OVERRIDE_FILE}`
|
||||
PLATFORM=$(<"${PLATFORM_OVERRIDE_FILE}")
|
||||
fi
|
||||
|
||||
URL="${CIPD_BACKEND}/client?platform=${PLATFORM}&version=${VERSION}"
|
||||
@@ -232,7 +232,7 @@ function self_update() {
|
||||
# so mismatches are very unlikely.
|
||||
INSTALLED_VERSION_FILE="${MYPATH}/.versions/.cipd_client.cipd_version"
|
||||
if [ -f "${INSTALLED_VERSION_FILE}" ]; then
|
||||
JSON_BODY=`cat "${INSTALLED_VERSION_FILE}"`
|
||||
JSON_BODY=$(<"${INSTALLED_VERSION_FILE}")
|
||||
if [[ "$JSON_BODY" != *"infra/tools/cipd/${PLATFORM}"* ]]; then
|
||||
>&2 echo "Detected CIPD client platform change to ${PLATFORM}."
|
||||
>&2 echo "Deleting the existing client to trigger the bootstrap..."
|
||||
|
||||
@@ -6,7 +6,7 @@ if [ "$OSTYPE" = "msys" ]
|
||||
then
|
||||
PYTHON3_BIN_DIR="$DEPOT_TOOLS/$(sed -e 's-\\-/-g' $DEPOT_TOOLS/python3_bin_reldir.txt)"
|
||||
else
|
||||
PYTHON3_BIN_DIR="$DEPOT_TOOLS/$(cat $DEPOT_TOOLS/python3_bin_reldir.txt)"
|
||||
PYTHON3_BIN_DIR="$DEPOT_TOOLS/$(<"$DEPOT_TOOLS/python3_bin_reldir.txt")"
|
||||
fi
|
||||
PATH="$PYTHON3_BIN_DIR":"$PYTHON3_BIN_DIR/Scripts":"$PATH"
|
||||
"$PYTHON3_BIN_DIR/python3" "$@"
|
||||
|
||||
@@ -8,7 +8,7 @@ then
|
||||
# this converts them to the forward slashes a unix environment expects.
|
||||
PYTHON_BIN_DIR="$DEPOT_TOOLS/$(sed -e 's-\\-/-g' $DEPOT_TOOLS/python_bin_reldir.txt)"
|
||||
else
|
||||
PYTHON_BIN_DIR="$DEPOT_TOOLS/$(cat $DEPOT_TOOLS/python_bin_reldir.txt)"
|
||||
PYTHON_BIN_DIR="$DEPOT_TOOLS/$(<"$DEPOT_TOOLS/python_bin_reldir.txt")"
|
||||
fi
|
||||
PATH="$PYTHON_BIN_DIR":"$PATH"
|
||||
"$PYTHON_BIN_DIR/python" "$@"
|
||||
|
||||
Reference in New Issue
Block a user