title: Unable to do a IF statement inside a bash heredoc
body: <p>I am trying to do a <code>IF..ELSE</code> inside a heredoc. The heredoc is necessary because the set of commands need to be executed as a different user. </p>
  
  <p>Unfortunately, the <code>IF</code> statement doesn't work as expected, and always jumps to the <code>ELSE</code> clause. When I remove the <code>IF</code> block from the heredoc and place it outside it works as expected. </p>
  
  <p>It is probably a simple thing I'm missing, but I have no idea what. </p>
  
  <pre><code>rem=0
  function1 () {
      su - user1 &lt;&lt;'DONE'
          if [[ "$rem" -eq 0 ]];
          then
              echo rem is even
          else
              echo rem is odd
          fi
  DONE
  
  }
  
  function1
  </code></pre>
  
  <p>It echoes rem is odd. </p>