title: Error codes seemingly ignored by '&&' on Windows command prompt
body: <p>I have some Batch scripts I use for automating application build processes, most of which involve chaining commands together using the <code>&amp;&amp;</code> operator. Admittedly, I'm more experienced with Linux, but based on that experience <code>some_command &amp;&amp; other_command</code> should result in <code>other_command</code> being run <strong>iff <code>some_command</code> returns an exit code of 0</strong>. <a href="https://stackoverflow.com/a/13719223">This answer</a> and <a href="https://stackoverflow.com/a/8055430">this answer</a> seem to agree with that. However this appears not to be the case on Windows cmd.exe, all of the scripts run regardless of the error code of the previous.</p>
  
  <p>I decided to make a simple test for this to convince myself I wasn't going insane. Consider this <code>test.bat</code>, which returns an exit code of 1:</p>
  
  <pre><code>@echo off
  EXIT /B 1
  </code></pre>
  
  <p>Running <code>test.bat &amp;&amp; echo This shouldn't print</code> prints 'This shouldn't print'. But since the exit code is clearly 1, <code>echo</code> should <em>not</em> be called. I've tested that the error code was actually 1 using the <code>%errorlevel%</code> variable, they're coming out as expected (0 before I run the script, 1 after).</p>
  
  <p>On Linux I tried the same thing. Here's <code>test.sh</code>:</p>
  
  <pre><code>#!/bin/bash
  exit 1
  </code></pre>
  
  <p>Running <code>./test.sh &amp;&amp; echo "This shouldn't print"</code> gives no output, exactly what I expected.</p>
  
  <p>What's going on here?</p>
  
  <p>(<strong>Note:</strong> OS is Windows 7 Enterprise)</p>