images-build: Handle errors.

This commit is contained in:
William Floyd 2020-05-27 18:17:51 -04:00
parent 5541b73e20
commit 05f04a30ee
Signed by untrusted user who does not match committer: william
GPG key ID: B3EEEDD81893CAF9

View file

@ -13,9 +13,12 @@ jpegoptim
fdp
zopflipng'
__fatal_error='false'
while read -r __program; do
if ! which "${__program}" &>/dev/null; then
echo "Error: Need '${__program}'"
echo "Need '${__program}'"
__fatal_error='true'
fi
done <<<"${__needed_programs}"
@ -67,6 +70,13 @@ PNG_SCALE'
# Functions
###############################################################################
__fatal_error_handler(){
if [ "${__fatal_error}" == 'true' ]; then
echo 'Fatal Error: Exiting'
exit
fi
}
########################################
# __set_env <env file>
########################################
@ -340,6 +350,8 @@ __check_file() {
###############################################################################
__fatal_error_handler
{
pushd "$(dirname "$0")"