From c8f9c918bb5cf5385447c54994fab6b9e196c08e Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Thu, 6 Dec 2012 02:51:31 +0100 Subject: check-hosts: fix parameter handling --- check-hosts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/check-hosts b/check-hosts index 13bdecc..f49a786 100755 --- a/check-hosts +++ b/check-hosts @@ -94,11 +94,17 @@ mode should be one of the following: EOU } -optarr=( $(getopt -o 'absecn' --long 'all,bad,stale,extra,cron,nagios' -- "$@") ) +ARGS="$(getopt -o 'absecn' --long 'all,bad,stale,extra,cron,nagios' -- "$@")" + +if [ $? -ne 0 ]; then + show_usage + exit 1 +fi + +eval set -- "$ARGS" -i=0 while true; do - case ${optarr[$i]} in + case "$1" in -a|--all) get_all exit 0 @@ -129,7 +135,7 @@ while true; do exit 1 ;; esac - ((i++)) + shift done exit 0 -- cgit v1.2.3-1-g7c22