title: How can I simply retrieve the absolute path of the current script (multi OS solution)?
body: <p>I am looking for a simple solution to retrieve the absolute path of the current script. It needs to be platform independent (I want it to work on linux, freebsd, macos and without bash).</p>
  
  <ul>
  <li>"readlink -f $0" works on linux but not on freebsd and macos: readlink
  doesn't have the "-f" option.</li>
  <li>"realpath $0" works on freebsd and linux but not on macos: I don't have this command.</li>
  </ul>
  
  <p>EDIT : 
  Solution for retrieve the path of the repository of the script :</p>
  
  <p>DIR="$( cd "$( dirname "$0" )" &amp;&amp; pwd )" (source : <a href="https://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in#comment3818043_246128">Getting the source directory of a Bash script from within</a> )</p>