title: .SHELLFLAGS assignment in makefile
body: <p><strong><em>From the <a href="https://www.gnu.org/software/make/manual/html_node/One-Shell.html#One-Shell" rel="nofollow noreferrer">docs</a>:</em></strong></p>
  
  <blockquote>
    <p>...You can modify <code>.SHELLFLAGS</code> to add the <code>-e</code> option to the shell which will
    cause any failure anywhere in the command line to cause the shell to
    fail...
    <br>
    <br></p>
  </blockquote>
  
  <p><strong><em>So, given the following makefile:</em></strong></p>
  
  <pre class="lang-make prettyprint-override"><code>.SHELLFLAGS = -e -c
  
  define cmd
  echo true
  true
  endef
  
  all::
      $(shell $(cmd))
  </code></pre>
  
  <p><strong><em>Running, I get:</em></strong></p>
  
  <pre class="lang-console prettyprint-override"><code>truetrue
  /bin/sh: 1: truetrue: not found
  makefile:10: recipe for target 'all' failed
  make: *** [all] Error 127
  </code></pre>
  
  <p>Did you see that (in the 1st line of output)? <strong><em>truetrue?</em></strong> Where did it come from?</p>
  
  <p>Let's compare it with the following <strong><em>identical</em></strong> makefile, where <code>-e</code> was not added to <code>.SHELLFLAGS</code>.
  <br>
  <br>
  <strong><em>The makefile, would be:</em></strong></p>
  
  <pre class="lang-make prettyprint-override"><code># Do you see the difference, from the previous Makefile?
  # Here, the value is '-c' alone. No '-e' flag is present here!
  .SHELLFLAGS = -c
  
  define cmd
  echo true
  true
  endef
  
  
  all::
      $(shell $(cmd))
  </code></pre>
  
  <p><strong><em>Running, I get:</em></strong></p>
  
  <pre class="lang-console prettyprint-override"><code>true true
  </code></pre>
  
  <p>Much better!</p>
  
  <p>So, we have here 2 versions of makefile, both run <strong>identical</strong> commands, where the first version also added the <code>-e</code> flag to <code>.SHELLFLAGS</code>. </p>
  
  <p>The results however - for the respective runs - were not consistent! We had:</p>
  
  <ol>
  <li>Expands to the <em>trivial</em> command <code>true true</code>, which is analogous to the trivial command <code>: true</code> (i.e "ignore arguments..."), and therefore an exit-status: 0.
  
  <ul>
  <li>This was for the "simple" run, without the change in <code>.SHELLFLAGS</code>. (version 2).</li>
  </ul></li>
  <li>As for the first run, Make went ahead, and condensed the command to <code>truetrue</code> (really?), hence: a meaningless command and a fatal error from the shell.</li>
  </ol>
  
  <p>In summary: It seems that adding <code>-e</code> to <code>.SHELLFLAGS</code> is not that <em>innocent</em> as the documentation suggested above.</p>
  
  <p>In fact, Make, then (when .SHELLFLAGS is modified to include <code>-e</code>), and only then - Make takes the liberty to do some more (unexpected?) modification to the command, resulting - for example - here with the command <code>truetrue</code> for a <code>true true</code> command.</p>
  
  <p>Really?</p>
  
  <p>(Versions-note: All versions supporting <code>.SHELLFLAGS</code>, which is 3.82 and up).</p>