Guard against zero value

This commit is contained in:
Ivan Ilves 2017-04-22 19:56:23 +02:00
parent 253a6f830a
commit 67bc01e9c5

View File

@ -42,8 +42,12 @@ while getopts "f:RDrh" o; do
case ${o} in case ${o} in
f) f)
MAX_FAILED_PINGS=${OPTARG} MAX_FAILED_PINGS=${OPTARG}
if [[ ! ${MAX_FAILED_PINGS} =~ [0-9]{1,} ]]; then if [[ ! ${MAX_FAILED_PINGS} =~ ^[0-9]{1,}$ ]]; then
echo "'-f' option accepts only integer values" echo "'-f' option accepts only positive integer values"
exit 1
fi
if [[ ${MAX_FAILED_PINGS} -eq 0 ]]; then
echo "'-f' option value should be greater then zero"
exit 1 exit 1
fi fi
;; ;;