title: Weird behaviour of $BASH_SOURCE
body: <p>If you have foo.sh that declares a global function:</p>
  
  <pre><code>myfunction(){ echo $*;}
  declare -fx myfunction
  </code></pre>
  
  <p>And you source it:</p>
  
  <pre><code>. foo.sh
  </code></pre>
  
  <p>And then you call the global function from bar.sh:</p>
  
  <pre><code>myfunction $BASH_SOURCE
  myfunction a b c
  myfunction $BASH_SOURCE
  </code></pre>
  
  <p>The third call produces a blank line, unless bar.sh is being sourced. Any ideas how to bypass this problem?</p>