Better exit handling

This commit is contained in:
Marcus Noble 2020-12-13 16:21:23 +00:00
parent 00e8364d30
commit a9167d1214

View File

@ -1,6 +1,5 @@
#!/bin/bash #!/bin/bash
EXIT_CODE=0
FAILED_MESSAGE="" FAILED_MESSAGE=""
GITEA_TOKEN=${GITEA_TOKEN:?is not set} GITEA_TOKEN=${GITEA_TOKEN:?is not set}
@ -56,7 +55,6 @@ for REPO in ${REPOS}; do
git remote add gitlab "${GITLAB_BASE}${REPO}" git remote add gitlab "${GITLAB_BASE}${REPO}"
failed() { failed() {
EXIT_CODE=1
printf "\n⚠ Failed to sync ${REPO}\n\n" printf "\n⚠ Failed to sync ${REPO}\n\n"
cd .. cd ..
@ -83,5 +81,8 @@ for REPO in ${REPOS}; do
printf "\n✅ Successfully synced ${REPO}\n\n" printf "\n✅ Successfully synced ${REPO}\n\n"
done done
printf ${FAILED_MESSAGE} if [ ! -z ${FAILED_MESSAGE} ];
exit ${EXIT_CODE} then
printf ${FAILED_MESSAGE}
exit 1
fi