Get directory of the executed script in bash


Simple, straight forward:

SCRIPTPATH="$( cd "$(dirname "$0")" >/dev/null 2>&1; pwd -P )"