Skip to content

Commit 8f6e1fb

Browse files
authored
Use 'command -v' instead of 'which' for required command check (#44)
1 parent 3774696 commit 8f6e1fb

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

check_rancher2.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
# 20220909 1.10.0 Allow ignoring statuses on workload checks (#29) #
5454
# 20230110 1.11.0 Allow ignoring workload names, provisioning cluster not critical (#39) #
5555
# 20230202 1.12.0 Add local-certs check type #
56+
# 20231208 1.12.1 Use 'command -v' instead of 'which' for required command check #
5657
##########################################################################################
5758
# (Pre-)Define some fixed variables
5859
STATE_OK=0 # define the exit code if status is OK
@@ -61,7 +62,7 @@ STATE_CRITICAL=2 # define the exit code if status is Critical
6162
STATE_UNKNOWN=3 # define the exit code if status is Unknown
6263
export PATH=/usr/local/bin:/usr/bin:/bin:$PATH # Set path
6364
proto=http # Protocol to use, default is http, can be overwritten with -S parameter
64-
version=1.12.0
65+
version=1.12.1
6566
##########################################################################################
6667
# functions
6768

@@ -190,7 +191,7 @@ exit ${STATE_UNKNOWN}
190191
#########################################################################
191192
# Check for necessary commands
192193
for cmd in jq curl; do
193-
if ! `which ${cmd} 1>/dev/null`; then
194+
if ! `command -v ${cmd} 1>/dev/null`; then
194195
echo "UNKNOWN: ${cmd} does not exist, please check if command exists and PATH is correct"
195196
exit ${STATE_UNKNOWN}
196197
fi

0 commit comments

Comments
 (0)