Perform CLI argument validation as early as possible

This commit is contained in:
Mislav Marohnić 2014-11-26 19:45:52 -08:00
parent 38ae3b56b0
commit 22c73bf3f5
3 changed files with 6 additions and 9 deletions

View file

@ -1022,6 +1022,8 @@ for option in "${OPTIONS[@]}"; do
esac
done
[ "${#ARGUMENTS[@]}" -eq 2 ] || usage 1
DEFINITION_PATH="${ARGUMENTS[0]}"
if [ -z "$DEFINITION_PATH" ]; then
usage
@ -1046,9 +1048,6 @@ elif [ "${PREFIX_PATH#/}" = "$PREFIX_PATH" ]; then
PREFIX_PATH="${PWD}/${PREFIX_PATH}"
fi
# Fail if number of arguments is not equal to 2
[ "${#ARGUMENTS[@]}" -eq 2 ] || usage
if [ -z "$TMPDIR" ]; then
TMP="/tmp"
else