Fix command line argument parsing

This commit is contained in:
Jonny007-MKD 2021-01-17 12:59:36 +01:00
parent f363bc15e2
commit 30a21e5d2e
1 changed files with 3 additions and 4 deletions

View File

@ -22,22 +22,20 @@ while [[ $# -gt 0 ]]; do
''|*[!0-9]*) echoerr "Value for \"$1\" has to be a number"; exit -3;; ''|*[!0-9]*) echoerr "Value for \"$1\" has to be a number"; exit -3;;
esac esac
WARN=$2 WARN=$2
shift; shift shift
;; ;;
-c|--crit|--critical) -c|--crit|--critical)
case "$2" in case "$2" in
''|*[!0-9]*) echoerr "Value for \"$1\" has to be a number"; exit -3;; ''|*[!0-9]*) echoerr "Value for \"$1\" has to be a number"; exit -3;;
esac esac
CRIT=$2 CRIT=$2
shift; shift shift
;; ;;
-f|--fahrenheit) -f|--fahrenheit)
FAHRENHEIT=true FAHRENHEIT=true
shift
;; ;;
-d|--debug) -d|--debug)
DEBUG=true DEBUG=true
shift
;; ;;
-?|--help) -?|--help)
echo "Check /proc/mdstat. Arguments:" echo "Check /proc/mdstat. Arguments:"
@ -82,6 +80,7 @@ if $FAHRENHEIT; then
fi fi
log "$temp$unit. Warn: $WARN, Crit: $CRIT"
c=$(bc <<< "$temp > $CRIT") c=$(bc <<< "$temp > $CRIT")
w=$(bc <<< "$temp > $WARN") w=$(bc <<< "$temp > $WARN")