From 67bc01e9c5eefcd974d76e1f648b5ed95ba3a82b Mon Sep 17 00:00:00 2001 From: Ivan Ilves Date: Sat, 22 Apr 2017 19:56:23 +0200 Subject: [PATCH] Guard against zero value --- xiringuito | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/xiringuito b/xiringuito index 6d023e4..4f5979d 100755 --- a/xiringuito +++ b/xiringuito @@ -42,8 +42,12 @@ while getopts "f:RDrh" o; do case ${o} in f) MAX_FAILED_PINGS=${OPTARG} - if [[ ! ${MAX_FAILED_PINGS} =~ [0-9]{1,} ]]; then - echo "'-f' option accepts only integer values" + if [[ ! ${MAX_FAILED_PINGS} =~ ^[0-9]{1,}$ ]]; then + 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 fi ;;