According to POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sh.html
there are some cases where it not obvious. For example:
I believe you can get it using readlink:
scriptPath=$(readlink -f -- "$0") scriptDirectory=${scriptPath%/*}