[fx] Do not unconditionally exit from fx-cmd-locked
Only exit from fx-cmd-locked if the command failed.
Change-Id: I20131749e591b3651b05774a7d41d67ac9eef93f
diff --git a/devshell/lib/vars.sh b/devshell/lib/vars.sh
index 7e7de20..e6602a8 100644
--- a/devshell/lib/vars.sh
+++ b/devshell/lib/vars.sh
@@ -251,7 +251,7 @@
function fx-try-locked {
if ! command -v shlock >/dev/null; then
# Can't lock! Fall back to unlocked operation.
- "$@"
+ fx-exit-on-failure "$@"
elif shlock -f "${FX_LOCK_FILE}" -p $$; then
# This will cause a deadlock if any subcommand calls back to fx build,
# because shlock isn't reentrant by forked processes.
@@ -266,6 +266,9 @@
function fx-cmd-locked {
# Exit trap to clean up lock file
trap "[[ -n \"${FX_LOCK_FILE}\" ]] && rm -f \"${FX_LOCK_FILE}\"" EXIT
- "$@"
- exit $?
+ fx-exit-on-failure "$@"
+}
+
+function fx-exit-on-failure {
+ "$@" || exit $?
}