title: How can I source multiple bash scripts into each others properly?
body: <p>Let us say I have the following script files:</p>
  
  <p><em>~/src/setup.sh:</em>:</p>
  
  <pre class="lang-sh prettyprint-override"><code>#!/usr/bin/env bash
  
  dn=$( dirname "$0" )
  source "$dn/init/init.sh"
  </code></pre>
  
  <p><em>~/src/init/init.sh</em>:</p>
  
  <pre class="lang-sh prettyprint-override"><code>#!/usr/bin/env bash
  
  dn=$( dirname "$0" )
  source "$dn/start.sh"
  
  start_servers "param1" "param2"
  </code></pre>
  
  <p><em>~/src/init/start.sh</em>:</p>
  
  <pre class="lang-sh prettyprint-override"><code>#!/usr/bin/env bash
  
  start_servers() {
    # ...
    printf "start the servers..."
    # ...
  }
  </code></pre>
  
  <p>Sourcing the second file (<em>start.sh</em>) results that:</p>
  
  <pre><code>$ ./setup.sh
  ./init/init.sh: line 4: ./start.sh: No such file or directory
  ./init/init.sh: line 6: start_servers: command not found
  </code></pre>
  
  <p>Since I execute the <em>setup.sh</em> from <code>.</code>, after sourcing the files, <em>start.sh</em> seems to be sourced from <code>.</code> as well but I would like to source it from its proper location.</p>
  
  <p>Any idea how to fix it? Thanks in advance.</p>