diff --git a/kvmstats b/kvmstats index 9e9166b..fed124e 100755 --- a/kvmstats +++ b/kvmstats @@ -2,6 +2,11 @@ set -e +error () { + echo "$0": "$@" >&2 + exit 1 +} + usage () { echo 'usage: kvmstats [-a] [-u k|m|g]' >&2 exit 1 @@ -9,11 +14,7 @@ usage () { for DEP in bc virsh do - if [ -z "$(which $DEP)" ] - then - echo "kvmstats: $DEP not found in \$PATH" >&2 - exit 1 - fi + command -v $DEP > /dev/null || error $DEP command not found done POW=$(echo 1024 ^ 3 | bc)