fixing bash if statement issues related to negation

This commit is contained in:
forest 2021-02-17 21:19:27 -06:00
parent 8d5e3d007d
commit 64db728731

View File

@ -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