From 5cfbc705f84846da845e880ce958beb4a0820ded Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Fri, 22 Oct 2021 13:42:18 +0200 Subject: [PATCH] Let's try the --version flag before falling back to grep for the constant --- evocheck.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/evocheck.sh b/evocheck.sh index ab952fd..610d48a 100755 --- a/evocheck.sh +++ b/evocheck.sh @@ -1412,9 +1412,13 @@ get_version() { # /path/to/my_command --get-version # ;; - ## When there is just an internal variable name + ## Let's try the --version flag before falling back to grep for the constant kvmstats | add-vm) - grep '^VERSION=' "${command}" | head -1 | cut -d '=' -f 2 + if ${command} --version > /dev/null 2> /dev/null; then + ${command} --version 2> /dev/null | head -1 | cut -d ' ' -f 3 + else + grep '^VERSION=' "${command}" | head -1 | cut -d '=' -f 2 + fi ;; ## General case to get the version