title: Bash Boolean testing
body: <p>I am attempting to run a block of code if one flag is set to true and the other is set to false. ie</p>
  
  <pre><code>var1=true
  var2=false
  if [[ $var1 &amp;&amp; ! $var2 ]]; then var2="something"; fi
  </code></pre>
  
  <p>Since that did not evaluate the way that I expected I wrote several other test cases and I am having a hard time understanding how they are being evaluated.</p>
  
  <pre><code>aa=true 
  bb=false
  cc="python"
  if [[ "$aa" ]]; then echo "Test0" ; fi
  if [[ "$bb" ]]; then echo "Test0.1" ; fi
  if [[ !"$aa" ]]; then echo "Test0.2" ; fi
  if [[ ! "$aa" ]]; then echo "Test0.3" ; fi
  if [[ "$aa" &amp;&amp; ! "$bb" ]]; then echo "Test1" ; fi
  if [[ "$aa" &amp;&amp; ! "$aa" ]]; then echo "Test2" ; fi
  if [[ "$aa" ]] &amp;&amp; ! [[ "$bb" ]]; then echo "test3" ; fi
  if [[ "$aa" ]] &amp;&amp; ! [[ "$cc" ]]; then echo "test4" ; fi
  if [[ $aa &amp;&amp; ! $bb ]]; then echo "Test5" ; fi
  if [[ $aa &amp;&amp; ! $aa ]]; then echo "Test6" ; fi
  if [[ $aa ]] &amp;&amp; ! [[ $bb ]]; then echo "test7" ; fi
  if [[ $aa ]] &amp;&amp; ! [[ $cc ]]; then echo "test8" ; fi
  </code></pre>
  
  <p>When I run the preceding codeblock the only output I get is </p>
  
  <blockquote>
    <p>Test0<br>
    Test0.1<br>
    Test0.2  </p>
  </blockquote>
  
  <p>however, my expectation is that I would get</p>
  
  <blockquote>
    <p>Test0<br>
    Test1<br>
    Test3<br>
    Test5<br>
    Test7</p>
  </blockquote>
  
  <p>I have tried to understand the best way to run similar tests, however most examples I have found are set up in the format of<br>
      if [[ "$aa" == true ]];<br>
  which is not quite what I want to do. So my question is what is the best way to make comparisons like this, and why do several of the test cases that I would expect to pass simply not?</p>
  
  <p>Thank you!</p>