title: Jenkins pipeline when condition print expression rather than compare
body: <p>I have to write a pipeline that Builds Terraform infrastructure on Monday and destroy on Friday. I'm trying to determine whether to build or destroy depending on the result of <code>$(date '+%a')</code>, so here's what the condition looks like at the moment:</p>
  
  <pre><code>when {
        beforeAgent true
        expression { 
                   // Using 'Wed' because today is Wednesday
                    return  sh(returnStdout: true, script: '$(date +%a)') == 'Wed'
        }
  }
  </code></pre>
  
  <p>The only problem is every time I ran it, Jenkins shell print the result of <code>sh(returnStdout: true, script: '$(date +%a)')</code> rather than as a comparison value.</p>
  
  <pre><code>[Pipeline] sh
  14:52:03 [teardown] Running shell script
  14:52:04 + date +%a
  14:52:04 + Wed
  14:52:04 /jenkins-slave/workspace/teardown@tmp/durable-524bef20/script.sh: 2: /jenkins-slave/workspace/teardown@tmp/durable-524bef20/script.sh: Wed: not found
  </code></pre>
  
  <p>What am I doing wrong here?</p>
  
  <p>P.S I'm very new to Jenkins like 2 days of use, apologies in advance if I'm being blunt.</p>