diff options
-rwxr-xr-x | functions/stagefile.sh | 41 |
1 files changed, 16 insertions, 25 deletions
diff --git a/functions/stagefile.sh b/functions/stagefile.sh index 6f9e8cc8b..383df2c45 100755 --- a/functions/stagefile.sh +++ b/functions/stagefile.sh @@ -63,37 +63,28 @@ Remove_stagefile () rm -f "${FILE}" } +# Find at least one of the required stages, `exit 1` if none found Require_stagefile () { - local NAME - local FILES - local NUMBER - NAME="$(basename ${0})" - FILES="${@}" #must be on separate line to 'local' declaration to avoid error - NUMBER="$(echo ${@} | wc -w)" - + if [ $# -eq 0 ]; then + Echo_warning "Bad `Require_stagefile` usage, no params were supplied" + return 0 + fi local FILE - local CONTINUE=false - for FILE in ${FILES} - do - FILE=".build/${FILE}" - # Find at least one of the required stages - if [ -f ${FILE} ] - then - CONTINUE=true - NAME="${NAME} $(basename ${FILE})" + for FILE in ${@}; do + if [ -f ".build/${FILE}" ]; then + return 0 fi done - if ! $CONTINUE - then - if [ "${NUMBER}" -eq 1 ] - then - Echo_error "%s: %s missing" "${NAME}" "${FILE}" - else - Echo_error "%s: one of %s is missing" "${NAME}" "${FILES}" - fi + local NAME + NAME="$(basename ${0})" - exit 1 + if [ $# -eq 1 ]; then + Echo_error "%s requires stage: %s" "${NAME}" "${FILE}" + else + Echo_error "%s requires one of these stages: %s" "${NAME}" "$(echo ${@})" fi + + exit 1 } |