Home > Software engineering >  Bash if a variable is equal to true
Bash if a variable is equal to true

Time:12-16

I want to check if the variable is equal to the true keyword and if it is then do something accordingly but it is behaving in an undefined way. don't get what I want its a simple question but thank you : >

STRICT=$false

if [ "$STRICT" == $true ] # i am not sure about this line what should i do
  then  
  FS="${FS} hey"
fi

CodePudding user response:

Just use strings true and false, not variables.

STRICT=false

if [ "$STRICT" = true ]
then  
  FS="${FS} hey"
fi

And the standard string comparison operator is =. == is a bash extension.

  •  Tags:  
  • bash
  • Related