title: Does git bash create a subshell by default when running a script file?
body: <p>Im exploring a bit on shell scripts and wrote this script. When the build command fails, it has to provide an error message and exit.</p>
  <p>I know that exit 1 would close the current shell its running on. And the exit statement is within a curly braces (meaning that its executed on the same shell). But when this script is run as <code>./testScript.sh</code> it stops executing test(), testTwo() is not called, and the terminal remains open.</p>
  <p>While this is exactly the functionality i'm looking for, my question is why doesn't it close the terminal due to the exit 1; command? Does git bash creates a subshell by default when running a script?</p>
  <p>I know its not because its been called within a function. I did try running the exit statement in script without a function, and it still doesnt close the terminal.</p>
  <p>Any insights on the actual working of git bash and exit command would be highly useful.</p>
  <p>Thanks!</p>
  <pre><code># testScript.sh
  
  function test() {
      dotnet build -c Debug sample.csproj || { echo -e &quot;${RED}=== Build Failed&quot;;  exit 1; }
  }
  
  function testTwo() {
      echo &quot;== executing test two function.&quot;
  }
  
  function all()
  {
      pushd .
    test
    testTwo
      popd
  }
  
  all &quot;$@&quot;
  </code></pre>