title: How can I find the path to a script being sourced in dash?
body: <p>I am trying to have a sourced shell script determine its own location, and I have found that this is a difficult task for dash.</p>
  
  <p>In bash, sh, and csh, I can use: <code>$_</code>. </p>
  
  <p>In fish, I can use <code>(status -f)</code>. </p>
  
  <p>In dash, I have had no luck...</p>
  
  <p>I have tried sourcing the path.sh file shown below with the following results:</p>
  
  <pre><code># path.sh
  called=$_
  echo called:      $called
  echo underscore:  $_
  echo zero:        $0
  echo dash_source: $DASH_SOURCE
  echo bash_source: $BASH_SOURCE
  </code></pre>
  
  <p><code>dash -c ". path.sh"</code></p>
  
  <p>outputs:</p>
  
  <pre><code>called:      /usr/local/bin/dash
  underscore:  /usr/local/bin/dash
  zero:        dash
  dash_source:
  bash_source:
  </code></pre>
  
  <p>How can I get the path to path.sh in dash?</p>