From 64db728731da5404a1283feda08b82a9bed66caa Mon Sep 17 00:00:00 2001 From: forest Date: Wed, 17 Feb 2021 21:19:27 -0600 Subject: [PATCH] fixing bash if statement issues related to negation --- capsulflask/shell_scripts/get.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/capsulflask/shell_scripts/get.sh b/capsulflask/shell_scripts/get.sh index 74ec705..ff7af37 100755 --- a/capsulflask/shell_scripts/get.sh +++ b/capsulflask/shell_scripts/get.sh @@ -10,12 +10,12 @@ fi # this will let us know if the vm exists or not exists="false" state = "unknown" -if ! virsh domuuid "$vmname" | grep -qE '^[\t\s\n]*$'; then +if virsh domuuid "$vmname" | grep -vqE '^[\t\s\n]*$'; then exists="true" state_code="$(virsh domstats $vmname | grep state.state | cut -d '=' -f 2)" - if ! printf "$state_code" | grep -qE '^[0-8]$'; then + if printf "$state_code\n" | grep -vqE '^[0-8]$'; then printf 'state_code was not detected. state_code %s must match ^[0-8]$\n' "$state_code" exit 1 fi