toolbox: Fix running toolbox on non-GCE hosts.
On non-GCE hosts, the docker-credential-gcr binary will fail outputing
nothing, which will cause the subsequent jq operation to fail. This
causes the script to exit early due to -o pipefail.
BUG=b/226564252
TEST=toolbox works on non-GCE hosts.
RELEASE_NOTE=none
Change-Id: Iffff172df92ae117d1c21edaac67eaf07b5e20a2
diff --git a/toolbox b/toolbox
index 4a0bda7..14c90b5 100755
--- a/toolbox
+++ b/toolbox
@@ -63,7 +63,7 @@
# --user flag in this case
credentials=$(echo "${registry_host}" | \
(/usr/bin/docker-credential-gcr get || true) 2>/dev/null | \
- jq -r '.Username + ":" + .Secret')
+ (jq -r '.Username + ":" + .Secret' || true))
if [[ -n "${credentials}" ]]; then
user_flags=('--user' "${credentials}")
fi