From a2c3e53856b3dba3cf45a12bead3571322375bf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guillaume=20Cor=C3=A9?= Date: Fri, 19 Jan 2018 19:00:33 +0100 Subject: [PATCH] use 'command' built-in command instead of 'which' --- check_galera_cluster | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) mode change 100644 => 100755 check_galera_cluster diff --git a/check_galera_cluster b/check_galera_cluster old mode 100644 new mode 100755 index 339195e..05ac832 --- a/check_galera_cluster +++ b/check_galera_cluster @@ -10,7 +10,7 @@ ST_UK=3 print_version() { echo "$VERSION $AUTHOR" -} +} print_help() { print_version $PROGNAME $VERSION @@ -43,19 +43,16 @@ print_help() { crit=2 fcp=0.1 -#check required tools check_executable() { - if [ -z "$1" ]; then echo "check_executable: no parameter given!" exit $ST_UK fi - if [ -z "$(which $1)" ]; then - echo "UNKNOWN: Cannot find $1" - exit $ST_UK + if ! command -v "$1" &>/dev/null; then + echo "UNKNOWN: Cannot find $1" + exit $ST_UK fi - } check_executable mysql