fixing bash if statement issues related to negation
This commit is contained in:
		@ -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
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user