title: Bash scripts extremely slow to start on OSX
body: <p>I'm having a problem where my bash scripts take an extremely long time to start.  At first I thought that it was something in the script itself, but a quick experiment disproved that.</p>
  
  <p>This is the example script</p>
  
  <pre><code>#!/bin/bash
  echo 'ping'
  </code></pre>
  
  <p>When I run it</p>
  
  <pre><code>$ time ./script.sh
  </code></pre>
  
  <p>I get</p>
  
  <pre><code>ping
  
  real    0m12.018s
  user    0m0.002s
  sys    0m0.002s
  </code></pre>
  
  <p>(I've even seen it go up to 17 seconds...) What's incredibly strange is that when I run it <em>the second time</em>, it goes instantly.</p>
  
  <pre><code>ping
  
  real    0m0.004s
  user    0m0.002s
  sys 0m0.002s
  </code></pre>
  
  <p>But when I edit the file again, it's back to the long wait.</p>
  
  <pre><code>$ echo 'echo test' &gt;&gt; gbr.sh
  $ time ./gbr.sh
  ping
  test
  
  real    0m13.021s
  user    0m0.003s
  sys 0m0.003s
  </code></pre>
  
  <p>It's almost like bash is compiling my script or something.  <em>Is there any way to debug this?</em>  It also doesn't seem to be anything with my <code>.bash_profile</code> - if I just put an echo on the first line of <code>.bash_profile</code> I still only see that after 10+ seconds.</p>
  
  <p>I've tried this in iTerm2 and in native Terminal - both have exactly the same issue.  This is on macOS Sierra - 10.12.3</p>