title: Combining pipe with exit status in bash shell script
body: <p>I have this <em>bash</em> shell-script command that causes <em>date</em> to run if <em>make</em> succeeds (terminates with zero exit status) and vice versa:</p>
  
  <pre><code>make &amp;&amp; date
  </code></pre>
  
  <p>but now I want to process its output e.g.</p>
  
  <pre><code>make | sed s/a/A/
  </code></pre>
  
  <p>If I do</p>
  
  <pre><code>make | sed s/a/A/ &amp;&amp; date
  </code></pre>
  
  <p><em>date</em> runs even when <em>make</em> fails.</p>
  
  <p>If I instead do</p>
  
  <pre><code>make &amp;&amp; date | sed s/a/A/
  </code></pre>
  
  <p>the <em>sed</em> processes <em>date</em>'s output instead of <em>make</em>'s.</p>
  
  <p>Would you know of any solution? Thanks!</p>
  
  <hr>
  
  <p>P.S. I've tried these:</p>
  
  <pre><code>(make | sed s/a/A/) &amp;&amp; date
  </code></pre>
  
  <p><em>date</em> still runs when <em>make</em> fails.</p>
  
  <pre><code>(make &amp;&amp; (date &gt; /dev/null)) | sed s/a/A/
  </code></pre>
  
  <p><em>date</em> doesn't run when <em>make</em> succeeds.</p>